test
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • addicted2web Friend
    #158188

    Hi every body,

    I want to split the title in the front page of JA SOCIAL template
    i founded the title block in the template directory (ja_social.v1.2.1htmlcom_contentfrontpage)

    <a href=”<?php echo $this->item->readmore_link; ?>”>
    <?php echo $this->escape($this->item->title); ?>
    </a>

    So, how can i use strln function here ?

    Thanks in advance

    thuanlq Friend
    #369931

    Hi,

    You can use strln function, and split the title as following:
    – On this file, assign title value to a variable, you can split this variable, then “echo” your shorten title as example:


    <a href="<?php echo $this->item->readmore_link; ?>">
    <?php
    /*echo $this->escape($this->item->title);*/
    $title_frontend = $this->escape($this->item->title);//assign title value to title_frontend variable.
    $count_string = strlen($title_frontend); // count chars of title
    $shorten_title = substr($title_frontend, 0, $count_string - 10); //shorten title
    echo $shorten_title; // echo my shorten title
    ?>
    </a>

    addicted2web Friend
    #370074

    Solved !
    Thank you

    addicted2web Friend
    #370078

    I tried this:

    <a href=”<?php echo $this->item->readmore_link; ?>”>
    <?php echo substr($this->item->title, 0, 40).’…’; ?>
    </a>

    and it works, is it a good idea ?

    thuanlq Friend
    #370130

    <em>@addicted2web 212749 wrote:</em><blockquote>I tried this:

    <a href=”<?php echo $this->item->readmore_link; ?>”>
    <?php echo substr($this->item->title, 0, 40).’…’; ?>
    </a>

    and it works, is it a good idea ?</blockquote>

    Yes, It is a good idea and simple solution

Viewing 5 posts - 1 through 5 (of 5 total)

This topic contains 5 replies, has 2 voices, and was last updated by  thuanlq 13 years, 11 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum