[Hack + Override] Better Core SEF for EventList Component!

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
DraX
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Oct 08, 2008 6:07 pm

[Hack + Override] Better Core SEF for EventList Component!

Post by DraX » Wed Oct 08, 2008 6:38 pm

Something I noticed myself and thought might be helpful to other users, is that the SEF capabilities within the current build of the excellent Eventslist module are a bit lacking. The following quick hack is therefore incredibly useful if you've used Template overrides to force the URLs generated for things other than just Event Details to use the builtin JRoute EventListHelperRoute, which many of them were not actually using before due to some ungodly reason.

If using Joomla's Core SEF with mod_rewrite, many will notice that if you have an Event or Venue page as a menu item, that if the link to that same page appears after you've clicked on it, EventList will make the mistake of trailing the URL with the viewname, details, and the item slug, giving you results like so:

Your normal link to the Eventlist component events view might be the following:
http://yourdomain.com/events

Therefore the normal link to a category list / category view would be as so:
http://yourdomain.com/events/categoryev ... MyCategory

But, if you add a menu item to link directly to "MyCategory," and let's say it was made a Sub Menu item to the Events menu item, all the links within eventlist to that specific category become the following if you've already done Template overrides to use the Route Helper:
http://yourdomain.com/events/MyCategory ... MyCategory

as opposed to what you're actually looking for which is like so:
http://yourdomain.com/events/MyCategory

This hack combines template overrides with a tiny code modification within the file com_eventlist/helpers/route.php so that if you've created a menu item that goes specifically to a category or venue

Below is an example of what the templates/your_template/html/com_eventlist/categoryevents(or whichever view within eventlist)/default_table.php file could contain for the venue portion of the data where it used to be just a basic Joomla link constructor:

Code: Select all

				<?php
				endif;
				if ($this->elsettings->showlocate == 1) :
				?>

					<td headers="el_location" align="left" valign="top">
						<?php						
						if ($this->elsettings->showlinkvenue == 1 ) :
							echo $row->locid != 0 ? "<a href='".JRoute::_(EventListHelperRoute::getRoute($row->venueslug,'venueevents'))."'>".$this->escape($row->venue)."</a>" : '-';
						else :
							echo $row->locid ? $this->escape($row->venue) : '-';
						endif;
						?>
					</td>
The table row which contains the category data could be replaced with the following:

Code: Select all

				<?php
				endif;

				if ($this->elsettings->showcat == 1) :
					if ($this->elsettings->catlinklist == 1) :
					?>

						<td headers="el_category" align="left" valign="top">
							<a href="<?php echo JRoute::_(EventListHelperRoute::getRoute($row->categoryslug,'categoryevents'))?>">
								<?php echo $row->catname ? $this->escape($row->catname) : '-' ; ?>
							</a>
						</td>

					<?php else : ?>

						<td headers="el_category" align="left" valign="top">
							<?php echo $row->catname ? $this->escape($row->catname) : '-'; ?>
						</td>
That's it for the TEMPLATE Portion!

Now here comes the HACK:

Open up JOOMLA_BASE_DIR/components/com_eventlist/helpers/route.php

On line 57, REPLACE the following code:

Code: Select all

		if($item = EventListHelperRoute::_findItem($needles)) {
			$link .= '&Itemid='.$item->id;
		};
with this:

Code: Select all

		if($item = EventListHelperRoute::_findItem($needles)) {
			$link .= '&Itemid='.$item->id;
			if ($item->ExactMatch == 1) {
				$link = 'index.php?Itemid='.$item->id;
			}
		};
Now, on Line 93, REPLACE

Code: Select all

				if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id) && ($item->published == 1) && ($item->access <= $access)) {
					return $item;
With this:

Code: Select all

				if ((@$item->query['view'] == $needle) && (@$item->query['id'] == $id) && ($item->published == 1) && ($item->access <= $access)) {
					$item->ExactMatch = 1;
					return $item;
Now if there is an exact match for the menu item, it will change the link to ONLY be the Menu Item ID. The hack portion should only used if you're using mod_rewrite (unless you want the links to just be index.php?ItemId=25 or whatever the number is). It actually renders URLs properly without SEF and only using the template override (not using the route.php hack), which is strange.

benjibook
Joomla! Apprentice
Joomla! Apprentice
Posts: 16
Joined: Thu Oct 30, 2008 8:50 am

Re: [Hack + Override] Better Core SEF for EventList Component!

Post by benjibook » Fri Jun 26, 2009 8:43 am

hello,

i don't understand where to put this code in eventlist:

Code: Select all

    <?php
            endif;

            if ($this->elsettings->showcat == 1) :
               if ($this->elsettings->catlinklist == 1) :
               ?>

                  <td headers="el_category" align="left" valign="top">
                     <a href="<?php echo JRoute::_(EventListHelperRoute::getRoute($row->categoryslug,'categoryevents'))?>">
                        <?php echo $row->catname ? $this->escape($row->catname) : '-' ; ?>
                     </a>
                  </td>

               <?php else : ?>

                  <td headers="el_category" align="left" valign="top">
                     <?php echo $row->catname ? $this->escape($row->catname) : '-'; ?>
                  </td>
thanks a lot
if you can take a look on my trouble '404 page not found on filter result with Eventlist": http://forum.joomla.org/viewtopic.php?f=428&t=407286

alex2001
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Wed Jan 14, 2009 10:19 am

Re: [Hack + Override] Better Core SEF for EventList Component!

Post by alex2001 » Fri Dec 25, 2009 9:13 am

I have big problem with Core SEF for EventList

http://forum.joomla.org/viewtopic.php?f=472&t=472035

could anybody help me?..


Locked

Return to “Templates for Joomla! 1.5”