[SOLVED] Dropdown menu linked to events from JEvents DB

T34 19 Nov, 2010
Hi All!

I try to include a dropdown menu to my chronoform parsed the list of the future events from JEvents component's DB like the module "JEvents latest" does.

I've find the string that may to display the format I need:
${eventDate}[!a:-${endDate(%H:%M)}]|${title}

However I'm not sure that it's possible to use this JE variables globally in Joomla.

The second way is to query from jos_jevents_vevdetail the values directly. I need 2 values: dtstart (start time) and summary (as the title). And I need to organize all of them to the string of dropdown menu like "5/12/2010, 11:00 - Title".

But I can't understand:
[list]
  • how to build a dropdown used this string or values?

  • how to query only the future events from DB jos_jevents_vevdetail to dropdown menu sorted from earlier to latest?

  • and how to submit to CF form only the date and title values in one phrase ("5/12/2010 - Title", for example)?
  • [/list]
    I'm not a coder, so I've try to find something similar here. But I haven't the result.

    There are tree files of "JEvents Latest" module that can query and display the data using format that I need:

    mod_latestnews.php
    <?php
    
    ... skiped...
    
    // no direct access
    defined('_JEXEC') or die('Restricted access');
    
    // Include the syndicate functions only once
    require_once (dirname(__FILE__).DS.'helper.php');
    
    $list = modLatestNewsHelper::getList($params);
    require(JModuleHelper::getLayoutPath('mod_latestnews'));


    helper.php
    <?php
    
    ... skiped...
    
    // no direct access
    defined('_JEXEC') or die('Restricted access');
    
    require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
    
    class modLatestNewsHelper
    {
    	function getList(&$params)
    	{
    		global $mainframe;
    
    		$db			=& JFactory::getDBO();
    		$user		=& JFactory::getUser();
    		$userId		= (int) $user->get('id');
    
    		$count		= (int) $params->get('count', 5);
    		$catid		= trim( $params->get('catid') );
    		$secid		= trim( $params->get('secid') );
    		$show_front	= $params->get('show_front', 1);
    		$aid		= $user->get('aid', 0);
    
    		$contentConfig = &JComponentHelper::getParams( 'com_content' );
    		$access		= !$contentConfig->get('show_noauth');
    
    		$nullDate	= $db->getNullDate();
    
    		$date =& JFactory::getDate();
    		$now = $date->toMySQL();
    
    		$where		= 'a.state = 1'
    			. ' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )'
    			. ' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'
    			;
    
    		// User Filter
    		switch ($params->get( 'user_id' ))
    		{
    			case 'by_me':
    				$where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')';
    				break;
    			case 'not_me':
    				$where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')';
    				break;
    		}
    
    		// Ordering
    		switch ($params->get( 'ordering' ))
    		{
    			case 'm_dsc':
    				$ordering		= 'a.modified DESC, a.created DESC';
    				break;
    			case 'c_dsc':
    			default:
    				$ordering		= 'a.created DESC';
    				break;
    		}
    
    		if ($catid)
    		{
    			$ids = explode( ',', $catid );
    			JArrayHelper::toInteger( $ids );
    			$catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
    		}
    		if ($secid)
    		{
    			$ids = explode( ',', $secid );
    			JArrayHelper::toInteger( $ids );
    			$secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
    		}
    
    		// Content Items only
    		$query = 'SELECT a.*, ' .
    			' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
    			' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
    			' FROM #__content AS a' .
    			($show_front == '0' ? ' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' : '') .
    			' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
    			' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
    			' WHERE '. $where .' AND s.id > 0' .
    			($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
    			($catid ? $catCondition : '').
    			($secid ? $secCondition : '').
    			($show_front == '0' ? ' AND f.content_id IS NULL ' : '').
    			' AND s.published = 1' .
    			' AND cc.published = 1' .
    			' ORDER BY '. $ordering;
    		$db->setQuery($query, 0, $count);
    		$rows = $db->loadObjectList();
    
    		$i		= 0;
    		$lists	= array();
    		foreach ( $rows as $row )
    		{
    			if($row->access <= $aid)
    			{
    				$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
    			} else {
    				$lists[$i]->link = JRoute::_('index.php?option=com_user&view=login');
    			}
    			$lists[$i]->text = htmlspecialchars( $row->title );
    			$i++;
    		}
    
    		return $lists;
    	}
    }
    


    mod_latestnews.xml
    <?xml version="1.0" encoding="utf-8"?>
    <install type="module" version="1.5.0">
    	<name>Latest News</name>
    	<author>Joomla! Project</author>
    	<creationDate>July 2004</creationDate>
    	<copyright>Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.</copyright>
    	<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
    	<authorEmail>admin@joomla.org</authorEmail>
    	<authorUrl>www.joomla.org</authorUrl>
    	<version>1.5.0</version>
    	<description>DESCLATESTNEWS</description>
    	<files>
    		<filename module="mod_latestnews">mod_latestnews.php</filename>
    	</files>
    	<params>
    		<param name="count" type="text" default="5" label="Count" description="The number of items to display (default 5)" />
    		<param name="ordering" type="list" default="c_dsc" label="Ordering" description="Ordering options">
    			<option value="c_dsc">Recently Added First</option>
    			<option value="m_dsc">Recently Modified First</option>
    	  	</param>
    		<param name="user_id" type="list" default="0" label="Authors" description="A filter for the authors">
    			<option value="0">Anyone</option>
    			<option value="by_me">Added or modified by me</option>
    			<option value="not_me">Not added or modified by me</option>
    	  	</param>
    		<param name="@spacer" type="spacer" default="" label="" description="" />
    		<param name="show_front" type="radio" default="1" label="Frontpage Items" description="PARAMFRONTPAGEITEMS">
    			<option value="1">show</option>
    			<option value="0">hide</option>
    		</param>
    		<param name="secid" type="text" default="" label="Section ID" description="PARAMSECTIONID" />
    		<param name="catid" type="text" default="" label="Category ID" description="PARAMCATEGORYID" />
    		<param name="@spacer" type="spacer" default="" label="" description="" />
    		<param name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" description="PARAMMODULECLASSSUFFIX" />
    	</params>
    	<params group="advanced">
    		<param name="cache" type="list" default="1" label="Caching" description="Select whether to cache the content of this module">
    			<option value="1">Use global</option>
    			<option value="0">No caching</option>
    		</param>
    		<param name="cache_time" type="text" default="900" label="Cache Time" description="The time before the module is recached" />
    	</params>
    </install>
    


    I understand that there are the some answers in this files, but can't to find this answers.

    May be anybody has an experience of using JEvents or something similar with Chronoforms?

    Please, help me to find the example (if anybody have see this one) or show me how to do, if it's possible.
    GreyHead 20 Nov, 2010
    Hi T34,

    Sorry, that JEvents format string means nothing to me. I assume that it is some syntax that is specific to JEvents.

    Bob
    T34 21 Nov, 2010

    Sorry, that JEvents format string means nothing to me. I assume that it is some syntax that is specific to JEvents.



    May be you can help me to build the follow dropdown menu where X="something name field to query from JEvents database"? :wink:


    Menu parameters that I need:

    [list]
  • One first string is visible in the form, where the earliest event is (like "Y" value, for example).

  • When I click to this string, the menu drops down and shows all the strings with the future events, sorted from earlier to farthest.

  • When I click to the one of this events, form places it to the text field (like DatePicker does using dashboard).
  • [/list]

    I need only the code of this part of the form template and the template of current query, then I'll can try to handle the current name of the fields instead "X".

    It should be wonderful if you will may look at MySQL DB of my test site, where JEvents table had placed, and consult me a little how to query currently from different fields to CF. If you would can do that, I should ready to send you phpMyAdmin login of my test site immediately.
    GreyHead 21 Nov, 2010
    Hi T34,

    If you would can do that, I should ready to send you phpMyAdmin login of my test site immediately.


    By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look.

    Bob
    T34 21 Nov, 2010
    Hi Bob!

    Thanks, I have send you info using PM.
    T34 25 Nov, 2010
    Hi Bob!

    I did it, and dropdown menu works now. 🙂
    GreyHead 26 Nov, 2010
    Hi T34,

    Well done. I've been very busy these last few days and it hadn't got to the top of my list :-(

    Bob
    T34 26 Nov, 2010
    Hi Bob!

    I've been very busy these last few days and it hadn't got to the top of my list :-(



    Now problem. It was very difficult to find a solution, but the new concepts are appearing in my Zone of Proximal Development. :wink:

    I hope, your affairs of the last few days are completed successfully too. 🙂
    This topic is locked and no more replies can be posted.