We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

overwriting default values of URL-segments for homepage

Development and Programming

Komtur's avatar
Komtur
15 posts
14 years ago
Komtur's avatar Komtur

I found this documentation: http://ellislab.com/expressionengine/user-guide/development/usage/uri.html which is quite nice, but with this code

$product_id = $this->EE->uri->segment(3, 0);

I can only READ the value. How can I SET them?

How do I set (and overwrite the not-yet-existent) URL segement values of my start page (where all segments are empty)? I need to set them for all forthcoming templates.

Why do I want this? Of course I can write code like this in my templates:

{if segment_1 = "" OR segment_1 = "value_1"}...{/if}

But you get quite bored if you have to do this for many links…

       
the3mus1can's avatar
the3mus1can
426 posts
14 years ago
the3mus1can's avatar the3mus1can

They are stored in the segments array in the URI class: $this->EE->uri->segments.

       
Komtur's avatar
Komtur
15 posts
14 years ago
Komtur's avatar Komtur

Thanx a lot. That’s what I was searching for!

Code looks like this (if anyone’s interested) and works perfectly.

// predifine segments!!!
    if ($this->EE->uri->segment(1) == '' AND
        $this->EE->uri->segment(2) == '' AND
        $this->EE->uri->segment(3) == '') {
        $this->EE->uri->segments = array("1" => 'graphics',"2" => 'de', "3" => 'designer');
    }
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.