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.

url_title helper method doesn't honor global channel preference

May 16, 2011 2:49pm

Subscribe [3]
  • #1 / May 16, 2011 2:49pm

    Brian M.

    529 posts

    In the control panel,  I have used the setting here:

    admin->channel admin->global preferences->Word Separator for URL Titles

    to set the system to use the _ (underscore) when generating url_titles.

    If I put this code anywhere in a template or module/extension, it uses - (hypen) to create the url_title, ignoring the preference set in the CP.

    $this->EE->load->helper('url'); 
    echo url_title("hello chicago!");

    This generates:

    hello-chicago

    I’m assuming that’s a bug?

  • #2 / May 17, 2011 2:54am

    John Henry Donovan

    12339 posts

    Brain,

    No bug. When calling the helper like this you need to specify your choice

    <?php
    
    $this->EE->load->helper('url'); 
    echo url_title("hello chicago!", '_');
    
    ?>

    The preference in the CP is used at entry save time

  • #3 / May 17, 2011 9:37am

    Brian M.

    529 posts

    Oops. I’m still getting used to using EE2 - I keep forgetting to check the CodeIgnitor side of things.  Thanks!

  • #4 / May 17, 2011 11:51am

    Sue Crocker

    26054 posts

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

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

ExpressionEngine News!

#eecms, #events, #releases