Custom anynews htt template

crnogorac081

For other members how this is done:

rumen already had image inside Short_content field, so here is the code (using cwsoft anynews)


$config = array(
    'group_id_type' => 'group_id',
    'group_id' => 5,
    'display_mode' => 11,
    '$max_news_length'    => -1,   
    'max_news_items' => 3,
'allowed_tags' => '<p><a>',
    'custom_placeholder' =>  array('IMG_LINK' => '%img%')
);
echo getNewsItems($config);


in include.php there are modifications:

Around line 229, replacement
                                // remove tags from short and long text if defined
       //                         $row['content_short'] = ($strip_tags) ? strip_tags($row['content_short'], $allowed_tags) : $row['content_short'];
        //                        $row['content_long'] = ($strip_tags) ? strip_tags($row['content_long'], $allowed_tags) : $row['content_long'];

                                // remove tags from short and long text if defined
                               $row_content_short = ($strip_tags) ? strip_tags($row['content_short'], $allowed_tags) : $row['content_short'];
                               $row_content_long = ($strip_tags) ? strip_tags($row['content_long'], $allowed_tags) : $row['content_long'];

/*
                                // shorten news text to defined news length (-1 for full text length)
                                if ($max_news_length != -1 && strlen($row['content_short']) > $max_news_length) {
                                        // truncate text if user asked for using CakePHP truncate function
                                        $row['content_short'] = truncate($row['content_short'], $max_news_length);
                                }
*/

                                // shorten news text to defined news length (-1 for full text length)
                                if ($max_news_length != -1 && strlen($row_content_short) > $max_news_length) {
                                        // truncate text if user asked for using CakePHP truncate function
                                        $row_content_short = truncate($row_content_short, $max_news_length);
                                }

also in line 282

          //                              'CONTENT_SHORT'      => $row['content_short'],
          //                              'CONTENT_LONG'       => $row['content_long'],

                                        'CONTENT_SHORT'      => $row_content_short,
                                        'CONTENT_LONG'       => $row_content_long,


To explain:
In call options:
'allowed_tags' => '<p><a>', , this means I removed <img> tag from short_content
also, using this:
'custom_placeholder' =>  array('IMG_LINK' => '%img%')   it extracted image from short_content so you can use it in template using {{ news.SHORT_IMG_LINK_1 }} placeholder

But I needed to duplicate short_content because it will strip img tag first, and then there is no img tag to be extracted.

I hope it will help to others.

Cheers
Web developer

crnogorac081

{GROUP_IMAGE} is placeholder for Group image not post image.
Web developer

rumen

Hi there, I got issue with Anynews custom template (target is to make 3 responsible boxes horizontally with the last 3 news using the template classes)  - does not call it at all. Here is my code, if someone see where is the mistake please tell me:

<div class="anynews">
<section>
<div class="posts">
<article>
<h2>{TXT_HEADER}</h2>
<!-- BEGIN news_block -->
<a href="#" class="image"><img src={GROUP_IMAGE} alt="" /></a>
<h3>{TITLE}</h3>
<p>{CONTENT_SHORT}</p>
<!-- BEGIN readmore_link_block -->
<ul class="actions">
<li><a href={LINK} class="button">{TXT_READMORE}</a></li>
</ul>
<!-- END readmore_link_block -->
</article>
<!-- END news_block -->
</div>
</section>
</div>


Next issue - with all other standard  htt template I see the images as shape - but not the images itself - why doesn't show them? The images are in "media" folder. But when I open the image from the module the path is wrong. Where to point the right path? The module search the image in ../pages/ instead in ../media/