Page 1 of 1

TagCloud - friendly SEO URL

Posted: Sun Feb 10, 2008 11:24 pm
by fritzfs
Hello guys,
I've done some small changes in TagCloud extension if order to have clean URL.

file .htaccess :

Code: Select all

# TagCloud
RewriteRule ^tag/(.*)/$ index.php?&mact=Search,m99,dosearch,0&m99returnid=&m99searchinput=$1 [L
file function.tagcloud.php :
in function build_tagcloud($parameters, $array_rows) near the end of function where line looks like

Code: Select all

		$tag_array[$walk_counter] = '<a href="index.php?&mact=Search%2Cm99%2Cdosearch%2C0&m99'.
		'returnid='.$parameters[returnid].'&m99searchinput='.$row["word"] . '" style="font-size:'. $fontsize.
		'px;line-height:'. $fontsize.'px;'. $parameters[array_css][$arraypos].'" title="'.$parsed_link_title.'">' .
		$row["word"] . '</a>'; 

change that to:

Code: Select all

                $tag_array[$walk_counter] = '<a href="/tag/'.$row["word"].'/" style="font-size:'. 
		$fontsize.'px;line-height:'. $fontsize.'px;'. $parameters[array_css][$arraypos].'" title="'.$parsed_link_title.'">' .
		$row["word"] . '</a>';  

Re: TagCloud - friendly SEO URL

Posted: Sun Feb 10, 2008 11:25 pm
by fritzfs
URL after this will look like : http://www.domain.com/tag/keyword

Re: TagCloud - friendly SEO URL

Posted: Sun Feb 10, 2008 11:48 pm
by cubix
Thank you.

Are these changes for the latest version (2.0.2) ?

It would be nice if you could add this to the tracker in the forge under patches.

Re: TagCloud - friendly SEO URL

Posted: Mon Feb 11, 2008 12:12 pm
by fritzfs
Yes, these are the changes for latest function.tagcloud.php, I've just downloaded it couple of days ago.
Please notify me if you have any trouble getting it up&running.

Re: TagCloud - friendly SEO URL

Posted: Mon Feb 11, 2008 10:58 pm
by nivekiam
Sweet!  You've saved me from doing this.

Thank you!

Re: TagCloud - friendly SEO URL

Posted: Sun Feb 24, 2008 3:31 pm
by jo_hann
cubix wrote: Thank you.

Are these changes for the latest version (2.0.2) ?

It would be nice if you could add this to the tracker in the forge under patches.
Not necessary at all since I just dropped over this thread. I released a new version. Thanks for your participation here.
Please also consider answering my actual survey to give me an idea about the future development of the plugin...

Johann

Re: TagCloud - friendly SEO URL

Posted: Sun Feb 24, 2008 5:47 pm
by nivekiam
Thanks, just checking it out.  It works great.

I filled out the survey.  I answered no.  It's not something I need, not for my site, but might be a cool feature and might be of use to some people.

I also tested with this rewrite rule and it appears to work.
RewriteRule ^tag/(.*)\/([0-9]*)$ index.php?&mact=Search,m99,dosearch,0&m99returnid=$2&m99searchinput=$1

Maybe a note in the help file about if you specify a returnid when calling {tagcloud} to use that rewrite rule.  If you use that rewrite rule and don't specify a returnid, then it doesn't work.

Same if you specify a returnid and use this rewrite rule:
RewriteRule ^tag/(.*)$ index.php?&mact=Search,m99,dosearch,0&m99returnid=&m99searchinput=$1


Two things to note, both relating to not using the base meta tag   If you have CMSms to create a base meta tag, just stop here and ignore the rest as it may just confuse and create more work that you don't need to do.

First the more important one.
I had to add a condition to the rewrite rule to make Search work if searching from a /tag URL
Example:

Code: Select all

#Tags
RewriteCond %{REQUEST_URI} !.index\.php
RewriteRule ^tag/(.*)$ index.php?&mact=Search,m99,dosearch,0&m99returnid=&m99searchinput=$1
Now the other one:
I don't "showbase" with my meta data {metadata showbase='false'}

So I had to revise the function from:

Code: Select all

$tag_array[$walk_counter] = '<a href="tag/'.$row["word"];
to

Code: Select all

$tag_array[$walk_counter] = '<a href="/tag/'.$row["word"];
Otherwise I ended up with /tag/tag/tag etc if hitting a tag from a tag and then the search results wouldn't work.  You'd just get "No results for, tag/tag/tag/Home" or what ever your tag/search term had been.

You would of course need to change that if you have CMSms not installed at the root of your site, say you're testing it in a sub-directory.

I don't know if there is a better way to do any of the above, but it appears to work.

Hope this helps someone else, maybe add a note to the tagcloud help file.


Thanks for adding this functionality to the main release of tagcould.

Re: TagCloud - friendly SEO URL

Posted: Thu Mar 13, 2008 6:43 pm
by jo_hann
Ok nice to know your opinion about the survey. Unfortunately you are the only one who answered yet....

Well I added both rewrite rules in the same order to my .htaccess file and that works. Which means the first rule hits when I try to call with returnid otherwise the second rule hits.

I will include the link to this thread in the help file of the next release to point out your approach considering the base tag. Thanks for your post!

Re: TagCloud - friendly SEO URL

Posted: Fri Sep 12, 2008 1:08 pm
by applejack
Hi I am using version 2.6.2 of Tagcloud, CMS 1.4.1 News 2.8.2. I am having issues with the returnid not working which I am pretty sure is because of the htaccess file code I am using is below. It always shows the results in the home page and doesn't have clean urls and when you click on one of the results goes to 404 error page. I am using base href. I have tried using just one line of each htaccess and doesn't work either.

{tagcloud clean_urls="true" news_categories="Technology" returnid='51'}

RewriteRule ^tag/(.*)\/([0-9]*)$ index.php?&mact=Search,m99,dosearch,0&m99returnid=$2&m99searchinput=$1
RewriteRule ^tag/(.*)$ index.php?&mact=Search,m99,dosearch,0&m99returnid=&m99searchinput=$1

Also a useful addition to this plug-in would be for the news categories to show any subcategories based upon the parent name with an asterisk after it same as the News module options.