Page 1 of 1
[SOLVED] mix post type in news page
Posted: Sun May 31, 2015 1:03 pm
by giapippo
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
Re: mix post type in news page
Posted: Sun May 31, 2015 2:56 pm
by velden
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'.
Re: mix post type in news page
Posted: Mon Jun 01, 2015 12:06 pm
by giapippo
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

Re: mix post type in news page
Posted: Mon Jun 01, 2015 12:38 pm
by nikkio
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}
Re: mix post type in news page
Posted: Mon Jun 01, 2015 6:13 pm
by giapippo
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}
Re: mix post type in news page
Posted: Mon Jun 01, 2015 6:18 pm
by velden
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.
Re: mix post type in news page
Posted: Mon Jun 01, 2015 8:50 pm
by giapippo
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}
Re: mix post type in news page
Posted: Mon Jun 01, 2015 8:58 pm
by velden
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.
Re: mix post type in news page
Posted: Mon Jun 01, 2015 9:42 pm
by giapippo
hallo thanks for help
http://www.tabafactory.com/

?
thanks
Re: mix post type in news page
Posted: Tue Jun 02, 2015 6:42 am
by velden
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>
Re: mix post type in news page
Posted: Tue Jun 02, 2015 8:45 am
by giapippo
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}
Re: mix post type in news page
Posted: Tue Jun 02, 2015 9:00 am
by velden
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)
Re: mix post type in news page
Posted: Tue Jun 02, 2015 9:09 am
by giapippo
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

Re: mix post type in news page
Posted: Tue Jun 02, 2015 9:35 am
by velden
I'm sorry. Just see this typo:
{if $entry->fieldsbyname.youtube->value != ""}
Re: mix post type in news page
Posted: Tue Jun 02, 2015 10:08 am
by giapippo
ahahahahahhahahaha
{if $entry->fieldsbyname.youtube->value != ""}
velden you are mythical !!