ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Upping the default url segment limit

January 11, 2010 10:20am

Subscribe [4]
  • #1 / Jan 11, 2010 10:20am

    Joel Bradbury

    18 posts

    Out of the box EE only allows 10 segments.

    For a site we’re doing the client would like a way for the users to build up urls such as :

    /portfolio/{cat_url_title_1}/{cat_url_title_2}/{cat_url_title_3} ...

    which then returns a page with only items that exist in the categories specified in the url.
    Using lowe’s seg2cat http://loweblog.com/software/low-seg2cat/ and some extra custom bits this all works fine, until the 10th segment gets added.

    At that point it hits the limit in core.input.php, line 303.

    I’ve changed this to :

    if (count($ex) > 20)

    and nothing seems to have broken.

    Is there a valid reason (beyond it looking horrid) to stop url’s longer than 10 segments?

  • #2 / Jan 11, 2010 10:24am

    John Henry Donovan

    12339 posts

    Joel,

    I am not sure why you can’t just use regular category urls here

    using /portfolio/category/{cat_url_title_1}/ will dynamically provide entries for that category as will just having /portfolio/category/{cat_url_title_2}/.

    There is no need to tack on a different segment each time

  • #3 / Jan 11, 2010 10:29am

    Joel Bradbury

    18 posts

    I know what you mean, but by specifiying /portfolio/{cat_url_title_1}/{cat_url_title_2}/... we only want to return entries that are in all categories, inclusive so for the entries loop we’re using :

    exp:weblog:entries category="{segment_category_ids}"

    which ends up as

    exp:weblog:entries category="12&23;&3&4"

    or similar

    The only other way I can see to do that, would be to keep the cat_urls in the same segment but separate them via + or similar.

  • #4 / Jan 11, 2010 10:41am

    Matthew Pennell

    221 posts

    Personally I would not use URL segments for that purpose. There is a pre-existing definition for URL segments - they indicate a parent-child relationship, usually a hard-coded relationship between folders and files.

    For your example, I would use something like /portfolio/{cat1},{cat2},{cat3}/ - it’s still hackable but to my mind it implies more of an accurate relationship to the data you are returning. ‘Nested’ categories infers sub-categories IMHO.

  • #5 / Jan 11, 2010 10:41am

    John Henry Donovan

    12339 posts

    Joel,

    You could use the category_group parameter or indeed nest those categories under a parent category and just call that. I would probably need to know some more about what you are trying to achieve, what the URL setup is and what you have on the page

  • #6 / Jan 11, 2010 10:56am

    Joel Bradbury

    18 posts

    I agree with you Matt, it does then to indicate a child relationship. I’ll try and argue the case for non ‘/’ delimitation, see how it goes down.

    Can’t use the category group or parent nest ways, as there are currently 8 (possibly more later) categories across two category groups, and it needs to work with every combination of them.

    The other way that would (technically) work would be posting the data as a form, but it’d need a GET fallback anyway for promotional materials.

    Apart from that, I’ve got it working with all the various combos of cats/segments.

  • #7 / Jan 11, 2010 11:48am

    ender

    1644 posts

    could always code it for cat1,cat2,cat3 and use htaccess rewrites to present the user with the cat1/cat2/cat3 version.

  • #8 / Mar 02, 2010 10:23pm

    PixelGrinch

    48 posts

    Just out of curiosity now that you hacked segments > 9 into the core how would you call it ??? {segment_1}...{segment_9} works fine but {segment_10} and up don’t seem to work, any ideas ?

    thanks ...

    Out of the box EE only allows 10 segments.

    For a site we’re doing the client would like a way for the users to build up urls such as :

    /portfolio/{cat_url_title_1}/{cat_url_title_2}/{cat_url_title_3} ...

    which then returns a page with only items that exist in the categories specified in the url.
    Using lowe’s seg2cat http://loweblog.com/software/low-seg2cat/ and some extra custom bits this all works fine, until the 10th segment gets added.

    At that point it hits the limit in core.input.php, line 303.

    I’ve changed this to :

    if (count($ex) > 20)

    and nothing seems to have broken.

    Is there a valid reason (beyond it looking horrid) to stop url’s longer than 10 segments?

  • #9 / Mar 02, 2010 10:49pm

    PixelGrinch

    48 posts

    I found the answer to my question.
    to make {segment_10} + work you need to also alter the code in core.template.php ...

    Line     295:  ($i = 1; $i < 20; $i++)

    I have not seen any break in the system. If this can be confirmed by the development team I would be willing to write up a how to on increasing the number of segments. It made sense in my case as I was using segments to filter weblog entries by multiple custom field values without the use of a form. I needed 12 segments in total, thanks to Joel I am now able to do so ....

    thanks
    PixelGrinch

    ps.: using ee 1.6.8

  • #10 / Mar 02, 2010 11:20pm

    PixelGrinch

    48 posts

    I wrote up a quick How-To if you will:

    Using more than 10 Segments with ExpressionEngine

    PixelGrinch

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases