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

How to get URL TITLE?

Development and Programming

carvingCode's avatar
carvingCode
380 posts
15 years ago
carvingCode's avatar carvingCode

I want to add a ‘Read more’ link to the ‘Word Limiter’ plugin if there’s more text to be displayed.

Can someone give me a heads up of the specific API I can use?

TIA

       
carvingCode's avatar
carvingCode
380 posts
15 years ago
carvingCode's avatar carvingCode

Here’s what I came up with:

function Word_limit($str = '')
  {
    $this->EE =& get_instance();

    $total = ( ! $this->EE->TMPL->fetch_param('total')) ? 500 :  $this->EE->TMPL->fetch_param('total');        
    $total = ( ! is_numeric($total)) ? 500 : $total;

    // This fetchs a 2nd parameter from the tag.
    // Used in the link below.
    $title = $this->EE->TMPL->fetch_param('title');
        
    $str = ($str == '') ? $this->EE->TMPL->tagdata : $str;
        
    $my_returned_str = $this->EE->functions->word_limiter($str, $total);    
        
    if ($my_returned_str > $str) 
    {
      $this->return_data = $my_returned_str . "<span><a >[ read more ]</a></span>";
    } else {
      $this->return_data = $my_returned_str;
    }
}

I added a 2nd parameter (‘title’) which passes the {url_title} to the $title var.

       
blueAlien's avatar
blueAlien
11 posts
15 years ago
blueAlien's avatar blueAlien

You could run a query on the exp_channel_titles table to select the url_title that matches an entry_id.

       

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.