EE: Low Seg2Cat extension
This ExpressionEngine extension will make it easier to work with categories. This post now provides a place for support for the Low Seg2Cat extension.
Download and docs for Low Seg2Cat can be found in the Software section
This ExpressionEngine extension will make it easier to work with categories. This post now provides a place for support for the Low Seg2Cat extension.
Download and docs for Low Seg2Cat can be found in the Software section
Comments
Hi Low
Looks nice, we’ve always handled this with PHP as you can imagine, too bad this didn’t come out two weeks sooner, we could have used this in a project that is nearly finished.
Thanks for your work, will definitely consider this in future projects.
Low, I’ve always used PHP on my templates to get the category ID from a segment in the URL, so this looks good to me. I think I may be able to use this on my current project. Also adding this to the devot:ee (devot-ee.com) add-on library.
I must admit I underuse categories, but this looks seriously sweet :)
Nice addition to the EE plugin world! I definitely have a use for this on a site I’m working on now. Thanks!
Brilliant. Love you.
Is there a chance to get the {segment_n_category_url_title} ?
Would be awesome!
I just figured it out myself > I haven’t got a clue what I’m doing - but that seems to work:
add this line after line 106:
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_url_title’] = $row[’cat_url_title’];
This now works fantastically well for breadcrumbs etc ….
Joerg, that hack isn’t even necessary. This extension checks the url segments and compares them to the category_url_titles. So, if a category is found, then the segment equals the category_url_title.
In other words, {segment_n} == {segment_n_category_url_title} :-)
Just started using this plugin. Great help. As noted sometimes is nice to get rid of the CATEGORY word in the URL.
Thank you
This looks quite nice and will save the need for category in the url which I don’t like. Will give it a whirl soon.
How is it used?? Can someone please post an example so I know how to use it?
Thanks!
Tory. See if this example will clarify:
URL: example.com/animals
{exp:weblog:entries weblog="weblog_name" category="{segment_1_category_id}" }
List only entries that are assigned to the category named animals (in Category URL Title)
{/exp:weblog:entries}
This helps to create cleaner URLs and get rid of the “category” or “c” word from the url.
Thanks for the example, appreciate it. But…
It seems to work perfect on some categories, but not at all on a few. Seems that if the category id is more than one word (for example, I have a category that has two words and the url has a hyphen separating the words) it’s not working.
I tried using this:
{exp:weblog:entries weblog=”portfolio” category=”{segment_3_category_url_title}” }
But it’s not working either. Any help would be greatly appreciated.
Thanks.
Tory,
{segment_3_category_url_title}is not available, since it would be exactly the same as{segment_3}and therefore pointless. The category parameter in the weblog:entires tag expects an ID, so you’d have to use{segment_3_category_id}. And you should probably also adddynamic="off"to the weblog:entries tag.Hi - Is there an example on how this extension would be used?
Vani, you can use the variables made available with this extension in several ways. There is no one single purpose other than having the said variables available. So, if there’s a category url_title in the url, you could use
<title>{segment_3_category_name}</title>as your page title or{exp:weblog:entries weblog="my_blog" category="{segment_2_category_id}" dynamic="off"}to get all entries from the given category without the use of the Category URL Indicator.In short, just read the ‘What does it do’ bit and then ask yourself: can you think of an example on how this extension could be used?
Hi there, will this work with gallery categories, or would it be possible to add a parameter to specify that it does? :)
Hey Nathan. I’m afraid Gallery categories aren’t supported. Yet. :)
Thanks Lodewijk (how do you pronounce that?) for your excellent work here. I will definitely be using this beautiful solution in the future.
hi, can you list requirements? I get
“MySQL ERROR:
Error Number: 1146
Description: Table ‘OUexpEng.EE__extensions’ doesn’t exist”
thanks
is it possible that this extension won’t run in EE 1.6.7?
trying to enable it, I get the error above.
@pirco: as far as I know, this extension works with the latest EE build. Do other extensions work?
yes.
I’m on PHP5, btw.
Pirco, can you try a fresh copy? I made a small change — see how that works out.
yup, that works!
thanks for the personal attention. much appreciated.
I’ve seen the many examples in the comments, but I’m still having a hard time wrapping my brain around how to implement this.
Ideally, I would like my URL to look like: http://www.domain.com/category/movie-title/
I appreciate any other advice you could give. Thanks!
WOW! Sweet! If this works then I think you just saved my life. No need for /category/. No need to pass Cat_IDs. Thank you for reading my mind.
I have a question… (And it might be pre-mature since I haven’t read eveything nor even installed this yet) What happens if the segment is an entry URL? Or is it assumed that dynamic=”off”?
@earph and @Mark: setting up URL structures is totally up to you. In EE, you can set up any kind of URL structure you want, using the
{path="seg1/seg2"}variable.This extension does not build URLs for you, it merely looks at the current URI and fetches matching categories, which you can then use in your templates. This means that any match with a category url title is available. If the segment is an entry url title, and it doesn’t match a category url title, then the
{segment_n_category_...}variables will be empty. You get the variables, you decide how to work with them.This means, earph, that you could use the URL structure you want, but I can see a problem there. The first segment is usually used to identify the template group. This is good for keeping your templates structured and catching 404’s. In your case, the first segment is a dynamic value, which you’d have to read and manage in the index template of your default template group, which would be a challenge. You could also create as many template groups as there are categories, but that’s not something I’d recommend.
Thanks for the response low!
I managed to mix your extension in with the method found here: http://fortysevenmedia.com/blog/archives/setting_up_custom_category_url_structures_in_expressionengine/
It did allow me to set up the path exactly as I request, and you’re right IT IS a dynamic value. I hope it doesn’t make things too complicated down the road. Do you think I’ll have a problem using the method above? It seems like it’s handling the dynamic value really well.
Hey Low. Two more questions, if you don’t mind:
1) “If no matching category is found for a segment, an empty string is returned.” So the global is still created for the segment for the value is ” “, correct?
2) Does this work with Multi-Site Manager (MSM)?
This plugin looks great for how we’ve been approaching EE based sites. Perfect even! Now can someone tell me how to get rid of segment_1 so I can do mysite.com/category-A instead of mysite.com/some-template-folder/category-A? Basically I want my “root” / core pages to appear there and then use template folders for particular areas (e.g. blog, freelance, etc.)
Thanks again. I
Almost done with a new section of my site using this extension but am having difficulties with pagination, even using paginate_base - it just loops!
Has anyone figured out pagination use with low seg3cat?
@Mark: 1: Correct. 2: Yes.
You’ll need to set up some logic in the index template of your default template group. Try using embeds. Something like this:
{if segment_1_category_id != ''}{embed="group/template_1"}{/if}{if segment_1_category_id == ''}{embed="group/template_2"}{/if}
@mahalie: Dynamic pagination will be flaky if you use this approach. One way to work around this, is using the
offset=""parameter and setting its value in another segment. You could end up with URIs like this:/group/category1/50/and use this weblog:entries tag:{exp:weblog:entries category="{segment_2_category_id}" offset="{segment_3}" dynamic="off"}. You’d have to calculate the offset value yourself, though.We’ve implemented a multi-level hierarchical navigation by using only categories lately on a client site, for pagination, we had to use the
dynamic="off"approach by applying a small hack to the EE core: http://expressionengine.com/wiki/Enable_pagination_with_dynamic_offHi Lodewijk,
Would it be possible to update this so it accepts site=”site_short_name”, so on an MSM environment you can specify which site the category group belongs to?
Cheers!
Steve.
Can’t seem to get the category name, where the category has two words. Using dynamic=’off’. I see someone else mentioned this earlier. Is there a bug here? Or is there a fix?
Forget that last query - my template wasn’t updating for some reason. No bug :)
@Steve: what are you trying to do? I got the feeling it’s not this extension you’re having trouble with, but rather with the thing you’re trying to accomplish.
@Steve Abraham: this extension already is MSM-friendly — it only checks the categories belonging to the site you’re viewing.
Hello again Low…
Ok, still sounds great. I’m really anxious to try this. BUT… could you be so kind as to look at this EE forum topic I have going and offer your comments?
It would help a lot. Thx man.
http://expressionengine.com/forums/viewthread/121037/#599638
Low…
One more Q… What about category custom fields? Do you global those as well?
@Mark: if you’re having trouble with your site, please ask the EllisLab support crew — it’s what they’re there for. :) Seg2Cat does not include custom fields, because I wanted to make it simple and lightweight. You can use PHP or the Query module instead.
Hello again Low!
First, used your extension to “convert” a site I was about to take live. Brilliant! Gotta love those cleaner URLs
With regards to my other request (EE forum), it was related to multi-site manager, maybe this extension, and trying to provide the idea solution to the client. It wasn’t “tech support” as much as EE theory.
Thanks again. As I use this going forward I’m going to have to tack on a fee to my invoices to kick back to you :) Cheers!
Hi Low
I seem to have encountered a problem, don’t know if this was reported or not, but if there are multiple segments that are the same only one will get parsed out e.g.
/template_group/category_url_title/entry_title
where seg 2 and 3 are the same, 2 will not get assigned.
Made my own fix for it
$ids = array(); before the first foreach loop then inside after the data
$escaped_seg = $DB->escape_str($seg);
if( isset( $segs ) && in_array($escaped_seg, $segs) )
{
if( ! isset( $duplicates ) ) $duplicates = array();
if( ! isset( $duplicates[$escaped_seg] ) ) $duplicates[$escaped_seg] = array( $ids[$escaped_seg] );
$duplicates[$escaped_seg][] = $nr;
}
//
$ids[$escaped_seg] = $nr;
$segs[] = $DB->escape_str($escaped_seg);
then later.. just to give you the idea
// overwrite values in data array
$iter = 0;
$iter_end = 1;
$temp_ids = array( 0 => $ids[$row['cat_url_title']] );
if( isset ( $duplicates[$row['cat_url_title']] ) )
{
$iter_end = count($duplicates[$row['cat_url_title']]);
$temp_ids = $duplicates[$row['cat_url_title']];
}
for($iter; $iter < $iter_end; ++$iter)
{
$data['segment_'.$temp_ids[$iter].'_category_id'] = $row['cat_id'];
}
it got the job done =)
Awesome extension. Just what I need and saved me a top of time figuring out how to do this manually. Thanks!
lifesaver - thanks!
Any chance this could also return parent category information? I’m doing some menu work and need to know the ID of the parent category of the current category so I can set the menu state correctly.
Hey Mike. Sure, that’s actually quite an easy addition. As soon as I get Git working on Snow Leopard again, I’ll update the extension. Or just send me an email if you need it straight away.
Thanks!
Low,
The deeper one delves into EE, the greater the love of this community. About to code up something along these lines, I realise I don’t have to because the hard work has been done. Thank you, love you though we’ve never met.
Muchos,
3Easy.
This is extremely useful, and I’m thrilled that it’s available to use it on my current project. It’s perfectly handy in creating a tagging system, using EE’s categories, with clean URLs like http://somesite.com/tag/tagname for pages that show all the entries in a particular tag (category). Thanks! (And thanks to Boyink! for referring me to it in the forum.)
“If no matching category is found for a segment, an empty string is returned.”
In EE2 I’m not finding this to be the case, for example if segment 4 of a url is not in use, the raw text {segment_4_category_name} is returned and not an empty string.
Super useful code - many thanks.
Lee, if there is no {segment_4}, then {segment_4_category…} variables will not be set in the first place. In those cases, it’s better to do a check with a conditional:
{if segment_4} [...] {segment_4_category...} [...] {/if}Hi,
it doesn’t work in the new EE 2.
Paradise, version 2.2 does.
Hi Low,
i have the same proplem with Low Replace. If i go to Extensions or Plugins the github site shows up. On Seg2Cat i get this php errors at the bottom.
Message: Class Low_seg2cat_ext does not exist in (/mypath/expressionengine/third_party/low_seg2cat/ext.low_seg2cat.php)Filename: cp/addons_extensions.php
Line Number: 121
and
Message: Cannot modify header information - headers already sent by (output started at /mypath/expressionengine/third_party/low_seg2cat/ext.low_seg2cat.php:15)Filename: core/Common.php
Line Number: 421
Another question is - does now everything (plugin, ex, module go in the third_party folder?
Paradise, EE2 works with 3rd party packages. That means everything is put into the third_party folder, in its own directory. By the look of your paths, this is the case.
I cannot replicate your error. What 2.0 version are you using? The free trial, the freelancer or the (non)commercial version? Also, are there any other add-ons installed?
They are the only add-ons. You know i truncated the path :-)? The full path is
/var/www/work.mydomainCOM/htdocs/something.de/system/expressionengine/third_party/low_seg2cat/ext.low_seg2cat.phpIts v2.0.1pb01 and a free ride :-)
Paradise, still cannot reproduce. Can you install other add-ons without problems?
Ok, for a test i took Ryan Irelan’s “First Timer” extension and it works…
Looks like to me you’re trying to install version 1.x instead of the EE2 compatible version v2.2 (grab it at github).
Downloaded it again (what i did 3 times before) and the CP allways shows the github site. I found a thread in the EE forum where somebody had the same problem with another add-on.
Can i not post links here?
You can post links here. But maybe something is going wrong with the download from GitHub. I’ve zipped up a version you can download here: Low Seg2Cat v2.2.
Be sure to delete the other versions you downloaded.
Cool it works. So now i need also Low Replace :-)
Seems to be a github problem, cause the guy in the forum had the same problem with another add-on from github.
Low Replace v2.0
Thanks Low for your time/help. Now everything works. I’m to stuppid for github? Just right click and save - or?
To download from GitHub, just click the ‘Download Source’ button on the top right of the project page, below the search form and main menu.
first of all, thank you for the plugin.
question:
{if "{segment_2_category_id}" == "" OR "{segment_2_category_id}" == "{segment_2_category_id}"} aaaa {if:else}bbb{/if}doesn’t work even though {segment_2_category_id} is returned when there is no segment 2.
Is there a workaround? Why can’t it just be “” (nothing) instead of echoing the name of the function?
Daulex, what are you trying to accomplish? By the looks of it, something like this might be more appropriate:
{if segment_2}{if segment_2_category_id}aaa{if:else}bbb{/if}{/if}But beware — using this code as input for another tag will not work, because of the parse order.
Thank you for the swift reply.
That is pretty simple. I have yet to test it, but that’ll work.
The question remains, any chance the plugin could be improved to return a blank when the segment is not present?
I’m simply trying to pull the appropriate category based on the url segment. While pagination available at any stage.
I reworked the code you provided to:
{if segment_2}{if segment_2_category_id}{segment_2_category_id}{if:else}{segment_1_category_id}{/if}{/if}
I’m getting this error
Invalid EE Conditional Variable: {if segment_2_category_id}, which is what you probably warned me about.Thank you for taking the time to help me man.
Sorry for what’s looking like spam now, that only appears if there is no segment_2, otherwise works as expected, until I put it where I need it.
How’s this for a line of code:
{exp:channel:entries channel="products" limit="1" paginate="bottom" category="{if segment_2}{if segment_2_category_id}{segment_2_category_id}{if:else}{segment_1_category_id}{/if}{/if}"}Daulex, putting an advanced conditional (the one with
{if:else}) inside a parameter will not work. Make sure you know what the value is of the variable before using it as a parameter value.So, try this instead:
{if segment_2}{preload_replace:the_category="{segment_2_category_id}"}{/if}{if segment_1}{preload_replace:the_category="{segment_1_category_id}"}{/if}
{preload_replace:the_category=""}
{exp:channel:entries category="{the_category}"}
...
{/exp:channel:entries}
Dude, I love you.
That works… until I start using pagination :D
site.com/cat/ works
site.com/cat/P0 - breaks the whole thing as the_category goes blank :( which is why I was going to rely on using segment_2_category_id where you are now using if segment_2 in the first place.
I’m a wordpress heavyweight and really can’t believe that something that is so simple in wordpress is such a pain in ee. Really appreciate your time man.
Then there’s just one option, really. Use PHP on input in your template. That way you can check the value of the segments and set variables accordingly.
But since that has little to do with the Seg2Cat extension, I suggest you check out the EE Forums for help on that.
Thank’s Low, I understand the way it should work, however the only reason I asked you for help was the fact that your plugin echoes it’s own function call when there is no segment, which is extremely confusing. I just want to know if that can be avoided, as there is no way check against it.
Something as logical as
{if "{segment_2_category_id}" == "" OR "{segment_2_category_id}" == "{segment_2_category_id}"}Does not work. Which is why I asked you if the plugin can be improved.
Slight difference, the variable isn’t replaced if the segment isn’t present. If it should be replaced, then I need to set all variables for each possible segment (I believe 9 is the max at the moment). So, that means setting 9 x 5 = 45 variables, even when there’s no need.
I’ll need to look into performance before I make such changes, but your feature request is noted.
Hi,
how about a {last_segment_category_id}.
Maybee it can be done with the {last_segment} motification from the path.php.
I need to get the id from the last segment into the Channel/Weblog Entries Tag and don’t know how.
Paradise, I’ve updated the extension. There’s a new setting ‘Set all segments’, which will initiate all 9 possible segments. That should cater to your needs.
Hi Low
What’s the chance of getting {category_n_group_name} as well?
Plugin is pure gold by the way.
Hey Brendan,
Those chances are slim. I want to keep this extension as lightweight as possible, by only querying one table once. Adding the group name will require joining another table, which won’t be necessary in most cases.
You could use the query module, though. Something like this should do it:
{exp:query sql="SELECT group_name FROM exp_category_groups WHERE group_id = '{segment_n_category_group_id}'"} {group_name} {/exp:query}Thanks Low, worked a treat.
Hi - this doesn’t appear to be working for me - I’ve downloaded v1.3 and installed the language and extension files to the proper directories, but nothing shows up in my extensions list. When I attempt to run a trace (ex: {segment_4_category_id}) within the weblog entries tag, the tag reads as its literal interpretation, and nothing is rendered. Any ideas? I’m using expression 1.6.8
I get this in my extensions manager:
No direct script access allowed
What could be wrong :(?
Hey Low -
Having an odd issue on a client site where I’m using category=”{segment_4_category_id}”. I have a couple of multi-word category names where it works if I use underscores as separators, but not if I use dashes. One is “quick-release”, and the other is “fasteners-and-screws”. Other multi-word category names work fine. Any ideas?
Hey - love the extension. Question - is there a way to target the topmost parent category? Basically I have a 3rd level category, and I want to write a conditional that says “if segment_4_parent_parent_category_id == category_id” do something. Thanks in advance.
Hey Mikes. :)
Boyink: only thing I can think of why it doesn’t work as expected is that there are multiple categories with that url_title. Is that the case, perhaps?
Heavers: I try to keep seg2cat as light weight as possible, so that info isn’t available — you’ll have to use the Query module or some custom PHP to accomplish that.
Well, I wish it were that easy. Those category url titles are unique in the install.
Hmmm, okay. Are the {segment_4_category…} variables generating the any output for those category segments?
If possible, you could give me access to the EE install?
Yes - I’m using the name on the page, and if I display the ID it renders as well. I’ll shoot you access via email.
*cough* dynamic=”off” *cough*
Well - that’s odd. I hadn’t considered that because of the notes in the docs on specifying categories made it sound like by specifying a category id you were essentially telling the weblog entries tag to not be dynamic to begin with.
Odder that it only affected a couple of the categories.
Regardless - once again I prove that there’s always more to learn!
Thanks Low!
My idea is, that if you don’t need the tag to be dynamic, best to turn it off. It’s also a tiny bit faster in processing.
Hi - for some reason this works for a little while, then will suddenly give me an error message:
Warning: Invalid EE Conditional Variable: {if segment_4 == “home” OR segment_4_category_parent_id == “51″} in /home/***/public_html/manage/core/core.functions.php on line 2773
If I remove the segment_4_category_parent_id piece, it functions fine again (and I can even add that piece back in and have it work for awhile). Any idea why this is happening?
Hi Mike,
This looks like something you should ask the EllisLab team. If the problem is intermittent, it most likely has something to do with the way conditionals are parsed.
You can take Low Seg2Cat out of the equation, because it already did its work — register segment_n_category_x variables to the global variables array. The rest is done by EE’s template parser, so if something goes wrong there, it has to do with the way EE parses its global variables.
Only advice I can give you is to make sure you’re running the latest EE build.
Mike and Low, after experimenting with this, my inexperienced eye tells me that its due to the parse order of things. Since we are using advanced conditionals, there is something being messed up between EE and Seg2Cat.
I fixed this after some headscratching by writing less efficient simple IFs (aka boring ones).
For example, in use with Template Morsels:
{if segment_1}{if segment_2==""}
{if segment_1_category_id=="" }
<!-- INGENTING MED OBJEKT: -->
{exp:template_morsels:fetch name="vis-objekt" type="ingenting" blog="{my_weblog}" segment_1="{segment_1}"}
{/if}
{/if}
{/if}
I forgot to mention - I don’t know if my explanation is correct, or what is causing this.
I am using Seg2Cat 1.3 with EE 1.6.8, and after taking a look at the parse order list in the wiki, I would assume my advanced conditionals would work together with the Set all segments option turned on.
Instead, my log was telling me otherwise:
Invalid EE Conditional Variable: {if segment_1_category_id!="" && segment_2!=""}Invalid EE Conditional Variable: {if segment_1 && segment_1_category_id=="" && segment_2==""}Since segments are available and set before anything is parsed/evaluated, it should not give us that error - Am I right? (I understand this might be EllisLab-territory, but I hope you can help to shed some more light on this).
And Low, your a hero for making this. I have only recently become an active EE-user, but this sorted out one of my first and worst headaches.
Hi Low,
just a short question regarding the naming conventions
I assume, that Seg2Cat for EE 2 doesn´t accept category names with special characters and names, that consists of more than 1 word.
So, something like “alte Möbel” won´t work.
Is this right?
Fred: Check your EE 1.6.8 build. I think there were some issues with conditionals in earlier builds of that version.
Albert: Actually, Seg2Cat doesn’t really accept anything. It just looks at the URI, and if a segment matches a category url title, the variables are set, containing the values of that category. That would include any special characters.
Hi Low,
thanks for your explanation. So, special characters should be ok. I tried again and it stil not worked, so I looked at the tables directly within phpmyadmin, and
Möbel ist saved at M 246;bel (I just split it up, so one can see the the entity. I assume the different encodings are what it makes impossile to use special characters.
Now I just have to figure out, why categories like “alte moebel” do not work. I assume it´s also an encoding issue.
I’m having trouble using this correctly on an MSM site.
I have 2 sites each with their own templates and 1 set of weblogs. So I publish one weblog and it goes to two different sites with different templates.
Everything works fine on the default site but all the seg2cat fields in site 2 return null because it seems the categories belong to site 1.
Is there any way to fix this or add a site parameter like someone above suggested?
I fixed my problem above by removing
“AND site_id = ‘{$site}’” from lines 88-89 in your extension. That way it doesn’t respect the site of the category I’m trying to view.
I made a small change to add {last_segment_category_XX}
foreach ($query->result as $k => $row)
{
// overwrite values in data array
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_id’] = $row[’cat_id’];
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_name’] = $TYPE->light_xhtml_typography($row[’cat_name’]);
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_description’] = $row[’cat_description’];
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_image’] = $row[’cat_image’];
$cats[] = $row[’cat_id’];
if($ids[$row[’cat_url_title’]] == count($query->result))
{
$data[’last_segment_category_id’] = $row[’cat_id’];
$data[’last_segment_category_name’] = $TYPE->light_xhtml_typography($row[’cat_name’]);
$data[’last_segment_category_description’] = $row[’cat_description’];
$data[’last_segment_category_image’] = $row[’cat_image’];
}
}
Wow, I had that wrong, should be:
foreach ($query->result as $k => $row)
{
// overwrite values in data array
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_id’] = $row[’cat_id’];
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_name’] = $TYPE->light_xhtml_typography($row[’cat_name’]);
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_description’] = $row[’cat_description’];
$data[’segment_’.$ids[$row[’cat_url_title’]].’_category_image’] = $row[’cat_image’];
$cats[] = $row[’cat_id’];
if($ids[$row[’cat_url_title’]] == count($ids))
{
$data[’last_segment_category_id’] = $row[’cat_id’];
$data[’last_segment_category_name’] = $TYPE->light_xhtml_typography($row[’cat_name’]);
$data[’last_segment_category_description’] = $row[’cat_description’];
$data[’last_segment_category_image’] = $row[’cat_image’];
}
}
Hi Low,
Is there a chance to get category name from category_id in url with this extension. I’m trying to figure this out for days.
Tnxs for advance,
Ren
@Brian that is awesome.
I’d love to see it expanded by you or Low so that you could have {second_last_segment_category_id}. I can’t use the {last_segment_category_id} all the time because it fails on pages with Pagination, but if I had the {second_last_segment_category_id} I could get it to work.
Hey Low
As of now, {segment_x_category_id} returns the first category id the url title matches to. If you have several categories with the same name / url title across different weblogs, this messes things up. Just wanted to inquire wether you’re aware of this and maybe if you plan to add such feature (e.g., restricting the tags to a specific weblog).
Regards
Peter.
Hey Peter. I am aware of this, and there has been a caveat in the docs since version 1.0. :)
Bummer :) What’s the license for the extension, can I go and poke around? Do you by any change have it on GitHub or similar to we can fork it?
Don’t worry — I’ll take a look and see if I can add a setting to limit the query by category group.
I think this has changed. Has is not.
Hi there !
I can make the plugin work only for one category
when I go to example.com/template_group/template/category_1
I can see my category name, description and image
but if I go to example.com/template_group/template/category_2 or category_3 I have a blank page :(
here’s my code :
{exp:channel:entries channel=”products” category=”{segment_3_category_name}” dynamic=”off” category_group=”1″}
{segment_3_category_image} <h1>{segment_3_category_name}</h1> {segment_3_category_description}
{/exp:channel:entries}
Any ideas why ?
Thanks
William
Hey William. The category parameter expects an ID. So use {segment_3_category_id} instead of the name.
Wow ! thanks for the fast reply Low
it all works fine now :)
Hi again !
weird i can’t post
ho yes I can !
there is something I don’t understand. Let me explain :)
I want to have urls like this for category presentation page example.com/ template_group/ template/ name_of_category
which is done, thx to seg2cat
and I also want urls like this for the product page of one of the categories example.com/ template_group/ template/ name_of_category/ name_of_entry
how can I link to the products page from my category page with this url ?
If I put title_permalink it’s going to send to example.com/ template_group/ template/ name_of_entry
I managed it, thanks to this tut : http://fortysevenmedia.com/blog/archives/setting_up_custom_category_url_structures_in_expressionengine/
I just updated to EE2, and so I also updated to seg2cat v2.4.
I am now getting the following error:
“Severity: Notice
Message: Undefined index: News
Filename: extensions/ext.low_seg2cat.php
Line Number: 167″
The same error is cited for line numbers 168 - 172.
These errors only show up on pages with the URL mydomain.com/news/[…] — and I do have a category named “News”. I’m afraid the solution is obvious and I’m not seeing it… any help is appreciated!
akc, can you make sure the category url title is in all lowercase, both in the DB as in the URI?
Low, thanks for the speedy response!
I did a double-take reading your comment because I know I defined the category URL title in lowercase, as “news”, but it prompted me to scan all the rows in the exp_categories table. There I found another category called “News” with the URL title “News” — it was a remnant from the original EE installation which had some pre-defined default categories. I deleted that default category group, and now the errors are gone.
Thanks a ton. :)
Hey Low,
The extension seems to be running great except for one inconsistency I’m seeing. It *seems* to be affecting {comment_total} when I use {segment_n_category_id} when listing blog summaries. I can send you a link to the site that is currently live. When I disable the extension and hard-code the category id, it’s giving an accurate total.
Any suggestions are greatly appreciated.
Steve, I can’t see how Seg2Cat could affect {comment_total}. If it’s outputting the right category id (and I guess you checked that it does), then that’s all there is to it — it doesn’t do anything else…
I figured the same thing. I’m not sure if EE2 is having a caching issue or not. The Comments Total isn’t updating when a comment is posted. I’ll keep an eye on it. Thanks
Where are the docs for this extension? There appears to be notning on http://loweblog.com/software/low-seg2cat/docs/
Paul, there is something there. Between that and the overview, that’s all you need to know, as far as Seg2Cat is concerned.
Hi Low,
Just to say thanks!