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.

Links in channel inside PHP function not working

October 10, 2012 1:33am

Subscribe [1]
  • #1 / Oct 10, 2012 1:33am

    calendarfm

    7 posts

    I’m using v2.5.2. I am using PHP to limit the number of characters rendered from a channel entry. Everything works ok until I try use an a-tag in my channel entry “full_entry” field. 

    Here is the section of the template with the problem:

    {exp:channel:entries channel="blog" orderby="date" sort="desc" limit="3" pagination="bottom" }
    
                    <section><b><em>{summary}</em></b>
    
    
                      <?php
                          $position=400; 
    
                          $message="{full_entry}"; 
                          $post = substr($message, 0, $position); 
    
                          echo $post;
                          echo "..."; 
                        ?>
                      <div class="span8">
                        <span class="dateTime">Posted by <span class="author">{author}</span>
                        {categories}
                        <a href="http://{path=blog}">in {category_name}</a> •
                        {/categories}</span>
                        <a href="http://{url_title_path=blog/single}"> Permalink</a>
                      </div>
                      <div class="span3">
                      <a href="http://{url_title_path=%27blog/single%27}" class="readmore pull-right">Read More>></a>
                      </div>
                    </section>
                 
              {/exp:channel:entries}

    I do have PHP enabled on the template. Is this some problem with escaping?

    Thanks in advance,

    Justin

  • #2 / Oct 11, 2012 3:09pm

    Kevin Smith

    4784 posts

    Hi Justin,

    Rather than using PHP to do this, why not use a plugin like TruncHTML? I think that should help you avoid the problems you’re running into here.

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

ExpressionEngine News!

#eecms, #events, #releases