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.

Problem with segments on EE2.2.1

July 13, 2011 7:27am

Subscribe [2]
  • #1 / Jul 13, 2011 7:27am

    milogdm

    4 posts

    Hi.
    I’m getting a problem with segment:
    if I specify a segment like this:
    http://www.mysite.com/template/file/segment_1/

    and I use the {segment_1} in the template everything works fine, but if I put another string, such as:
    http://www.mysite.com/template/file/segment_3/segment_4
    I don’t get anything.

  • #2 / Jul 13, 2011 8:04pm

    Kevin Smith

    4784 posts

    Hi milogdm,

    Welcome to the forums! Could you provide us with your template code? What does the URL actually look like?

    It looks like there may be some confusion about segment variables as well. If your URL looks like this:

    <a href="http://example.com/company/employees/joe/">http://example.com/company/employees/joe/</a>

    ‘company’ is segment 1,
    ‘employees’ is segment 2,
    ‘joe’ is segment 3

    Does that make sense?

  • #3 / Jul 14, 2011 8:01am

    milogdm

    4 posts

    Happen that I need to keep the same structure of the old site, due to many external links.

    I have to keep a permalink structure like this to display a list of people in our company:

    /people/or /people/index.htm

    and a permalink structure like this to display details of a given person.

    /people/person_name or /people/person_name/index.htm

    I have a template group named “people” and I handle everything via the index.html template.

    The first condition is this:

    {if segment_2 == "index.htm" OR segment_2 == ""}
     >> display the fixed page with company description and a dynamic code that list people
        {exp:channel:entries channel="people"}
            <a href="http://{path=people/{url_title}}" target="_blank" rel="noopener">" alt=</a>
            <strong>{title}</strong>
        {/exp:channel:entries}
    {/if}

    in this case everything work fine if you specify /index.htm on the url, but if you have a permalink like http://www.example.com/people/ you get all person details.

    this is the second condition, to handle a single person specification:

    {if segment_2 != "index.htm" OR segment_2 != "" }

    if I’m under a single person url, for example /people/person_name everything works fine. If I have /people/person_name/index.htm

    I don’t get anything.
    This is the code for the second condition:

    {if segment_2 != "index.htm" OR segment_2 != "" }
    {exp:channel:entries channel="people" entry_id="{segment_3}"}
    {people_fields}
    {/exp:channel:entries}
    {/if}

    what is wrong?

  • #4 / Jul 14, 2011 11:44pm

    Lisa Wess

    20502 posts

    Hi, milogdm -

    The first step to troubleshooting a problem with conditionals is to echo the actual variables to the screen to see what EE is seeing.

    Can you put into your template:

    {segment_1}
    {segment_2}
    {segment_3}

    and let us know the URL and the echo’d output?

    Thanks!

  • #5 / Jul 18, 2011 8:25am

    milogdm

    4 posts

    Hi Lisa, and thanks for the reply.
    I have resolved the issue with an {if segment_2="..."}...{if:else}...{/if} to get a reciprocal exclusion of the view I need.

    Thank you

  • #6 / Jul 18, 2011 9:30am

    Sue Crocker

    26054 posts

    Glad Lisa was able to help. Don’t hesitate to post as as needed.

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

ExpressionEngine News!

#eecms, #events, #releases