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.

Comment group_id and path issues (may save people headaches)

March 17, 2014 8:15pm

Subscribe [1]
  • #1 / Mar 17, 2014 8:15pm

    Reverie123

    47 posts

    Just wasted some time on some really annoying comment issues, hope this post will help others that run into these problems.

    Problem 1:
    For some reason when you use the comment form you can’t use the group_id as a conditional. You can ACCESS the group_id but not parse with it. For example lets say you want to create a specific profile link for different member types; members group_id of 5 and premium member is 6:

    {exp:comment:entries}
    
    {if group_id = "6"}
     <a href="/premium-member">profile</a>
    {if:else}
      <a href="/member">profile</a>
    {/if}
    
    {/exp:comment:entries}

    No matter what you will get the else scenario.

    My solution was to enable php and ouput a specific string based on the group_id value.

    Problem 2:
    Now I can’t get template paths to work OR the site_url to show anything. The only option you have is {url_title_path} or create an absolute path (/shudders). The url_title_path will create a global path with the entry title attached to the end (Almost there, but not quite. So frustrating). This may be great in some scenarios, but I think people would prefer just to be able to use the site_url or paths for flexibility.

    My solution was to trim the end of the url_title_path using php. I did this by first grabbing the title value, replacing spaces with dashes and lowercasing it. Then I used rtrim php function to subtract that exact name from the end of the url. Tada! You now have the basic site_url address!

    $path= "{url_title_path}";  //sets path variable
    $title_url = str_replace(' ', '-', "{title}"); //replaces spaces with dashes
    $title_url = strtolower($title_url); //lower cases
    $clean_path = rtrim($path, $title_url); //your desired base path

    Note: using 2.6.1 and threaded comments 3rd party

  • #2 / Mar 18, 2014 11:22am

    ahmad saad

    364 posts

    Hi ,

    for first problem try to use group_id with parentheses:

    {exp:comment:entries}
    {if "{group_id}" = "6"}
     <a href="/premium-member">profile</a>
    {if:else}
      <a href="/member">profile</a>
    {/if}
    {/exp:comment:entries}

    for the second problem you can use the following code to get your site_url with PHP code::

    $this->EE->config->item('site_url')

    Regard’s.

  • #3 / Mar 18, 2014 8:19pm

    Reverie123

    47 posts

    Thanks, I knew there was a better solution then what I was doing :D

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

ExpressionEngine News!

#eecms, #events, #releases