Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
giapippo
Forum Members
Posts: 176 Joined: Tue Feb 28, 2012 1:24 pm
Post
by giapippo » Sun May 31, 2015 1:03 pm
hello to all
I have a news page that summarizes all the news site.
News are of 2 types with 2 different template
how can I bring up a page all news using their own template for each post summaries?
this is the website page
http://www.tabafactory.com/
some posts have pictures while others video
but with the tag {news}
I can not say use the template for video news category video
and use the template pictures for the news of the category photo
right?
or at least I do not know how to do it
thanks for help
Last edited by
giapippo on Tue Jun 02, 2015 10:08 am, edited 1 time in total.
velden
Dev Team Member
Posts: 3497 Joined: Mon Nov 28, 2011 9:29 am
Post
by velden » Sun May 31, 2015 2:56 pm
If I understand you correctly you want to have a page with all news items, which are a mix of 'video' items and 'photo' items. Right?
You need to use one template and inside the template check whether it's a video item or a photo item.
Code: Select all
pseudo code for template (both summary and detail):
...
{if $entry->fields.YOUTUBEVIDEOID->value != ''}
<!-- here the specific code for video items -->
{else}
<!-- here the specific code for NON video items -->
{/if}
...
Obviously YOUTUBEVIDEOID should be replaced with an alias you use for the field definition containing the 'video input'.
giapippo
Forum Members
Posts: 176 Joined: Tue Feb 28, 2012 1:24 pm
Post
by giapippo » Mon Jun 01, 2015 12:06 pm
like this summary template ?
Code: Select all
{if $entry->fields.youtube->value != ''}
{foreach from=$items item=entry}
<!-- blog-post -->
<div class="blog-post video-post">
<div class="inner-post">
<!-- youtube -->
<__iframe class="videoembed" src="http://www.youtube.com/embed/{$entry->fieldsbyname.youtube->value}"></__iframe>
<!-- End youtube -->
<div class="post-content">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}"><h2>{$entry->title|cms_escape}</h2></a>
<p> {if $entry->content}{eval var=$entry->content|truncate:200:"..."}{/if} </p>
</div>
</div>
</div>
{/foreach}
{else}
{foreach from=$items item=entry}
<!-- blog-post -->
<div class="blog-post gallery-post">
<div class="inner-post">
<div class="flexslider">
<ul class="slides">
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine1->value}" />
</li>
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine2->value}" />
</li>
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine3->value}" />
</li>
</ul>
</div>
<div class="post-content">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}"><h2>{$entry->title|cms_escape}</h2></a>
<p>{if $entry->content} {eval var=$entry->content|truncate:200:"..."}{/if}
</p>
</div>
</div>
</div>
{/if}
{/foreach}
but dont work
nikkio
Forum Members
Posts: 63 Joined: Sun Jun 08, 2008 12:34 pm
Post
by nikkio » Mon Jun 01, 2015 12:38 pm
I think you should put the if after the foreach..
Code: Select all
{foreach from=$items item=entry}
{if $entry->fields.$youtube->value != ""}
---youtube code
{else}
--- non youtube
{/if}
{/foreach}
giapippo
Forum Members
Posts: 176 Joined: Tue Feb 28, 2012 1:24 pm
Post
by giapippo » Mon Jun 01, 2015 6:13 pm
thanks for help but i think dont work
http://www.tabafactory.com/
my mews summary template now is:
Code: Select all
{foreach from=$items item=entry}
{if $entry->fields.youtube->value != ''}
<!-- blog-post -->
<div class="blog-post video-post">
<div class="inner-post">
<!-- youtube -->
<__iframe class="videoembed" src="http://www.youtube.com/embed/{$entry->fieldsbyname.youtube->value}"></__iframe>
<!-- End youtube -->
<div class="post-content">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}"><h2>{$entry->title|cms_escape}</h2></a>
<p> {if $entry->content}{eval var=$entry->content|truncate:200:"..."}{/if} </p>
</div>
</div>
</div>
{else}
<!-- blog-post -->
<div class="blog-post gallery-post">
<div class="inner-post">
<div class="flexslider">
<ul class="slides">
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine1->value}" />
</li>
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine2->value}" />
</li>
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine3->value}" />
</li>
</ul>
</div>
<div class="post-content">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}"><h2>{$entry->title|cms_escape}</h2></a>
<p>{if $entry->content} {eval var=$entry->content|truncate:200:"..."}{/if}
</p>
</div>
</div>
</div>
{/if}
{/foreach}
velden
Dev Team Member
Posts: 3497 Joined: Mon Nov 28, 2011 9:29 am
Post
by velden » Mon Jun 01, 2015 6:18 pm
You have an error in the content/template where you call the {news} tag.
Further: seems you're working on an older version of cmsms.
Read the help of the news module (or a sample template). Could well be that the correct syntax is : $entry->fiedsbyname.youtube->value
Maybe both are ok.
giapippo
Forum Members
Posts: 176 Joined: Tue Feb 28, 2012 1:24 pm
Post
by giapippo » Mon Jun 01, 2015 8:50 pm
ok now the site is not by mistake
but it continues to ignore the template summary of news
I tried setting it as the default
but nothing changes
definitely will be a trivial problem
again thanks for the help
new summary template :
Code: Select all
{foreach from=$items item=entry}
{if $entry->fiedsbyname.youtube->value != ""}
<!-- blog-post -->
<div class="blog-post video-post">
<div class="inner-post">
<!-- youtube -->
<__iframe class="videoembed" src="http://www.youtube.com/embed/{$entry->fieldsbyname.youtube->value}"></__iframe>
<!-- End youtube -->
<div class="post-content">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}"><h2>{$entry->title|cms_escape}</h2></a>
<p> {if $entry->content}{eval var=$entry->content|truncate:200:"..."}{/if} </p>
</div>
</div>
</div>
{else}
<!-- blog-post -->
<div class="blog-post gallery-post">
<div class="inner-post">
<div class="flexslider">
<ul class="slides">
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine1->value}" />
</li>
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine2->value}" />
</li>
<li> <img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine3->value}" />
</li>
</ul>
</div>
<div class="post-content">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}"><h2>{$entry->title|cms_escape}</h2></a>
<p>{if $entry->content} {eval var=$entry->content|truncate:200:"..."}{/if} </p>
</div>
</div>
</div>
{/if}
{/foreach}
velden
Dev Team Member
Posts: 3497 Joined: Mon Nov 28, 2011 9:29 am
Post
by velden » Mon Jun 01, 2015 8:58 pm
It's hard for us to troubleshoot the problem.
Create a new template and start with the basics:
For example.
Code: Select all
{foreach from=$items item=entry}
<pre>{$entry->fieldsbyname|print_r}</pre>
{if $entry->fiedsbyname.youtube->value != ""}
VIDEO!
{else}
PHOTO!
{/if}
{/foreach}
Try to understand what's happening and what properties you can check and use. etc. etc.
velden
Dev Team Member
Posts: 3497 Joined: Mon Nov 28, 2011 9:29 am
Post
by velden » Tue Jun 02, 2015 6:42 am
Seems to work right?
This code can be removed, it's used to get some insight in available properties you can use:
Code: Select all
<pre>{$entry->fieldsbyname|print_r}</pre>
giapippo
Forum Members
Posts: 176 Joined: Tue Feb 28, 2012 1:24 pm
Post
by giapippo » Tue Jun 02, 2015 8:45 am
hello I think you understand what could be the problem.
if I reverse the position of the code so I get a reverse result.
whereas before it was always taken the template photo and completely discarded the video, is now being used more and discarded photos and videos
why?
thanks for the help
Code: Select all
{foreach from=$items item=entry}
{if $entry->fiedsbyname.immagine1->value != ""}
<!-- blog-post -->
<div class="blog-post gallery-post">
<div class="inner-post">
<div class="flexslider">
<ul class="slides">
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine1->value}" />
</li>
<li>
<img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine2->value}" />
</li>
<li> <img alt="{title}" src="{$entry->file_location}/{$entry->fieldsbyname.immagine3->value}" />
</li>
</ul>
</div>
<div class="post-content">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}"><h2>{$entry->title|cms_escape}</h2></a>
<p>{if $entry->content} {eval var=$entry->content|truncate:200:"..."}{/if} </p>
</div>
</div>
</div>
{else}
<!-- blog-post -->
<div class="blog-post video-post">
<div class="inner-post">
<!-- youtube -->
<__iframe class="videoembed" src="http://www.youtube.com/embed/{$entry->fieldsbyname.youtube->value}"></__iframe>
<!-- End youtube -->
<div class="post-content">
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}"><h2>{$entry->title|cms_escape}</h2></a>
<p> {if $entry->content}{eval var=$entry->content|truncate:200:"..."}{/if} </p>
</div>
</div>
</div>
{/if}
{/foreach}
velden
Dev Team Member
Posts: 3497 Joined: Mon Nov 28, 2011 9:29 am
Post
by velden » Tue Jun 02, 2015 9:00 am
The test should work. But note that even a single space in that field would make the test fail (space is not an empty string)
giapippo
Forum Members
Posts: 176 Joined: Tue Feb 28, 2012 1:24 pm
Post
by giapippo » Tue Jun 02, 2015 9:09 am
the system ignores one of the two template
or use the template VIDEO or use the template for all PHOTOS
and excludes always the first tempalte immediately after the string
Code: Select all
{if $entry->fiedsbyname.immagine1->value != ""}
I forgot
the post titled
"Heavy Sand - Creative Photography" in the home page
is a PHOTOS post but use the VIDEO template
velden
Dev Team Member
Posts: 3497 Joined: Mon Nov 28, 2011 9:29 am
Post
by velden » Tue Jun 02, 2015 9:35 am
I'm sorry. Just see this typo:
{if $entry->fiel dsbyname.youtube->value != ""}
giapippo
Forum Members
Posts: 176 Joined: Tue Feb 28, 2012 1:24 pm
Post
by giapippo » Tue Jun 02, 2015 10:08 am
ahahahahahhahahaha
{if $entry->fieldsbyname.youtube->value != ""}
velden you are mythical !!