EllisLab text mark
Advanced Search
     
remove Category URL Indicator name?
Posted: 26 July 2008 03:06 AM
Avatar
Joined: 2007-12-04
924 posts

hi, I almost done with my wish url, I need remove the Category URL Indicator name called “category”:

I have this:
http://www.mysite.com/index.php/entertaiment/category/music

I remove the index.php and have this:
http://www.mysite.com/entertaiment/category/music

now I need remove “category” for get this final url:
http://www.mysite.com/entertaiment/music

how I can remove that?
thanks smile

 
Posted: 26 July 2008 04:12 AM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
29075 posts

You can’t do that, unless you use Cxx categories, like http://example.com/entertaiment/C12.

 
Posted: 26 July 2008 04:21 AM   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-04
924 posts

definely I cant? Cxx its more ugly that a name, but I need remove the entire name, with the parameter backspace=“6” it not possible, remove 6 characters? maybe I confuse with funtionally of that parameter…  mmm

you know looks better and more simple to remember to users remember this: http://www.mysite.com/entertaiment/music and not http://www.mysite.com/entertaiment/category/music

thanks

 
Posted: 26 July 2008 05:14 AM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
29075 posts

No, you can’t. Not easily, at any rate: some PHP, and perhaps querying the data directly from the db would get you there, I suppose, but out of the box, you can’t do it. And, no, the backspace parameter doesn’t do this.

I don’t think it’s much of an issue, very few users (if any) are going to type in the link to a category by hand, and your internal links, as well as Google & Co., won’t care.

That said, you can always rename “category” to something better suited for your site.

 
Posted: 26 July 2008 11:45 PM   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-04
924 posts

thanks Ingmar, well you have a reason that is not a big issue… so I think in better names… “tag” sounds good I think, any other name suggestions? for no use category? smile

 
Posted: 27 July 2008 07:39 AM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2002-02-05
462 posts

You could grab the segment containing the category_url_title, use a quick query to fetch the category ID, and use that as a parameter for your weblog tag.

Your URL would look like this (without the “Category URL Indicator”) so make sure your links also lose the indicator.

www.mysite.com/index.php/entertaiment/music

your category_url_title would be segment_2:

{exp:query sql="SELECT cat_id FROM exp_categories WHERE cat_url_title = '{segment_2}'"}

{exp
:weblog:entries weblog="your_weblog" category="{cat_id}"}
...
{/exp:weblog:entries}

{
/exp:query} 

Let me know if you need more help.

 
Posted: 27 July 2008 10:42 AM   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6513 posts

True, Cocoaholic, but certain tags would not recognize that you are on a category page, like the Category Heading tag.

 Signature 
 
Posted: 27 July 2008 10:49 AM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2002-02-05
462 posts

Indeed, but you can easily fetch it with the same query and add it, right?

{exp:query sql="SELECT cat_id, cat_name FROM exp_categories WHERE cat_url_title = '{segment_2}'"}

<h2>{cat_name}</h2>

{exp:weblog:entries weblog="your_weblog" category="{cat_id}"}
...
{/exp:weblog:entries}

{
/exp:query} 

Or am I missing the point?

 
Posted: 27 July 2008 04:45 PM   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2002-06-03
6513 posts

No, just that certain tags will not work as intended.

 Signature 
 
Posted: 22 December 2008 05:55 AM   [ # 9 ]   [ Rating: 0 ]
Joined: 2008-08-01
17 posts

I just found out that if you use a dot (’.’) as category indicator name, the ‘category’ URL segment is completely hidden from the URL. So it would be /entertainment/music in your particular case.

 
Posted: 22 December 2008 06:10 AM   [ # 10 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
29075 posts

This is certainly not a recommended method. I’ll try this myself, but would quite frankly be surprised if there were no ill side effects.

 
Posted: 22 December 2008 09:19 AM   [ # 11 ]   [ Rating: 0 ]
Joined: 2008-08-01
17 posts
Ingmar Greil - 22 December 2008 11:10 AM

This is certainly not a recommended method. I’ll try this myself, but would quite frankly be surprised if there were no ill side effects.

I was quite surprised that this works in the first place. However, I haven’t come across any side effects yet—and I’ve almost finished building the website. Coming from Textpattern, I’m missing the possibility to fine tune your URLs very much, so I was happy to find such a workaround.

 
Posted: 24 January 2009 02:25 AM   [ # 12 ]   [ Rating: 0 ]
Joined: 2008-12-26
13 posts

would be good to see an example of this? maybe a code snippet?