Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
User Site Design, Integration and Customization:
How to re-write $EVENT_TITLE into SEO Friendly Event URL
iLoveHouseMusic



Joined: 21 Apr 2009
Posts: 1482
Location: San Francisco CA

Posted: 06/05/11 10:21 
Just sharing this custom mod with you all. I'm gonna warn you YMMV on this because obviously this is custom to my site and PJ2 template but with this info you should be able to make it work. I'm sure there are different ways to do this so feel free to comment, maybe we can improve this method.

STEP 1. Add this to your .htaccess near the bottom

Code
#events
RewriteRule ^eid([0-9]+)/([A-Za-z0-9_-]+)/$ /ranking.php?mode=event&event_id=$1&old_events=true&row_template=event.tpl [QSA,L]


Your row template may vary depending on what Skin you're using. Also the old_events=true is so that the link is still viewable after the event is over.

STEP 2. Add this code to the TOP of the tpl that links to the main event.tpl. In the case of PJ2, this is on the row templates (event_row, event_gallery_row etc). regex_replace is part of smarty

Code
{assign var="RM1"   value=$EVENT_TITLE|trim|strtolower|replace:'?':''}
{assign var="RM2"   value=$RM1|regex_replace:"@[^a-z0-9]@i":' '}
{assign var="RM3"   value=$RM2|regex_replace:"@\s+@i":' '}
{assign var="EVENTSEO"   value=$RM3|replace:' ':'-'}


STEP3. Change your <a href> links appropriately. In my case:


Code
<a href="{$JAMROOM_URL}/eid{$EVENT_ID}/{$EVENTSEO}/" title="{$EVENT_TITLE}"><span class="highlight-txt">{$EVENT_TITLE}</span></a>


STEP4. had to make a minor edit the comment.php so that comments refresh properly
Find this line on comment.php

Code
$url = rtrim($_SERVER['HTTP_REFERER'],'/') .'#form';


And remove the trailing slash

Code
$url = rtrim($_SERVER['HTTP_REFERER'],'') .'#form';


I want to stop right here and warn you that I already have MOST of my other skin related content pages (blogs, events, videos, articles) rewriting the URL so if you have commenting enabled on those content pages be weary of this. Again, I'm thinking maybe there's a better approach to this but this is what works for me.

STEP 5. OPTIONAL - When a user saves/edits an event, I have the re-written Event URL posted at the top of the form so that the user can easily click to the new content page to see results. To do this you edit the calendar.php
Find this line

Code
jmLinkCell($language['calendar'][55], $eventidLink);


And add this code directly ABOVE it


Code
   $cleanET      = preg_replace("@[^a-z0-9]@i", " ", strtolower($_cal['event_title']));
   $cleanET      = preg_replace("@\s+@i", " ", $cleanET);
   $cleanET      = str_replace(' ', '-', $cleanET);
   $eventidLink  = '<a href="'.$jamroom['jm_htm'].'/eid' . $_cal['event_id'] . '/' . $cleanET.'/" target="_blank">'.$jamroom['jm_htm'].'/eid' . $_cal['event_id'] . '/' . $cleanET.'/</a>';

        jmLinkCell($language['calendar'][55], $eventidLink);



The one "problem" I'm having is that if a user adds an event with a special character at the end of title, for instance

Code
The Big Show @ Club Douchbag with DJ Cowboy Hat (Atlanta GA)

The event URL translates to:

Code
domain.com/eid123/the-big-show-club-douchbag-with-dj-cowboy-hat-atlanta-ga-/

It's more aesthetics but I'm trying to drop that trailing "-" If anyone can shed some light on that that'd be cool.

You may peep my site to see this all live. ENJOY!

Brian Cool

Back to top
whodaniel



Joined: 26 Jun 2006
Posts: 627

Posted: 06/18/11 01:52 
I'm curious what JR team has to say about your method; Is it more SEO friendly? And if so should changes to to core be considered?

Back to top
iLoveHouseMusic



Joined: 21 Apr 2009
Posts: 1482
Location: San Francisco CA

Posted: 06/18/11 07:33 
I think if Jamroom Developers tackled this they would take a completely different approach.

What I've done is more of a workaround.

Back to top
iLoveHouseMusic



Joined: 21 Apr 2009
Posts: 1482
Location: San Francisco CA

Posted: 06/25/11 12:56 
I can comment on this - If the event is added with enough time for google to index the page (for instance, 1 month early), I _HAVE_ had my site come up in google page 1 when searching specifically for that event.

I would think that the title has something to do with that. Obviously, my site is not solely dedicated to that 1 event, but the point is, the hit/connection was made.

Now imagine that for blog titles, video titles, etc...

Back to top
musichive-net



Joined: 24 Jan 2009
Posts: 266

Posted: 06/26/11 13:39 
Hi,

Nice idea.

Mike

Sorry for spamming but bookmarks get lost and I can always check my posts to find this topic Wink

Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
User Site Design, Integration and Customization

 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.