Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
duplicate article on individual article page
I’m working on a site which I use the code below (simplified by removing the html tags) but when I go to an individual page it seems that the code from the frontpage
is also parsed so I get the article and the titles twice.
The site is only using sections. I just can’t see where the bug is. Could somebody lent me an extra pair of eyes?
<txp:glx_if_frontpage>
<!-- is front page -->
<txp:image id="4" />
<txp:site_slogan />
<txp:article_custom id="1">
<txp:body />
</txp:article_custom>
</article>
<txp:recent_articles wraptag="ul" break="li" label="Recent Entries" />
<txp:else />
<txp:if_article_list>
<!-- is article list -->
<txp:images category='<txp:category_list type="image" parent="banners" break=","><txp:category type="image" /></txp:category_list>' limit="6" sort="rand()" wraptag="ul" break="li" class="rslides">
<txp:image />
</txp:images>
<txp:article_custom time="any" limit="999">
<txp:posted />
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
<txp:else />
<!-- is individual article -->
<txp:article allowoverride="0">
<txp:images category='<txp:if_custom_field name="bannerimagecategory"><txp:custom_field name="bannerimagecategory" /><txp:else /><txp:image id="4" /></txp:if_custom_field>' wraptag="ul" class="rslides" break="li">
</txp:images>
<txp:title />
<txp:body />
</txp:article>
<txp:variable name="future"><txp:article_custom section="events" wraptag="ul" break="li" time="future" label="Upcoming events" labeltag="h4"><txp:permlink><txp:title /></txp:permlink></txp:article_custom></txp:variable>
<txp:if_variable name="future" value="<h4>Upcoming events</h4>">
<txp:else />
<txp:variable name="future" />
</txp:if_variable>
<txp:variable name="past"><txp:article_custom section="events" wraptag="ul" break="li" time="past" label="Past events" labeltag="h4">
<txp:permlink><txp:title /></txp:permlink></txp:article_custom>
</txp:variable>
<txp:if_variable name="past" value="<h4>Past events</h4>">
<txp:else />
<txp:txp:variable name="past">
</txp:if_variable>
</txp:if_article_list>
</txp:glx_if_frontpage>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: duplicate article on individual article page
I’m not familiar with glx_if_frontpage, but your if-frontpage-else-if-article-list-else-individual-article logic looks good to me. What if you use <txp:if_section name="default"> … </txp:if_section>
as your frontpage detection method?
There are a few other mini-anomolies in your code – a stray closing article tag at the top, a txp:image tag in a category attribute, a double txp:txp:variable near the end that’s not properly closed – that may be causing the logic to break, but maybe they resulted from cutting and pasting in simplified form for the forum.
One other thing: your has-future-articles / has-past-articles test seems to be just to omit the heading if there are no results. Does txp:article_custom
return the label and labeltag when there are no results? I can’t remember but I would expect it to only produce the label if there are actually results, so you should be able to dispense with the variable check altogether.
Suggestion to try:
<txp:if_section name="default">
<!-- is front page -->
<txp:image id="4" />
<txp:site_slogan />
<article>
<txp:article_custom id="1">
<txp:body />
</txp:article_custom>
</article>
<txp:recent_articles wraptag="ul" break="li" label="Recent Entries" />
<txp:else />
<txp:if_article_list>
<!-- is article list -->
<txp:images category='<txp:category_list type="image" parent="banners" break=","><txp:category type="image" /></txp:category_list>' limit="6" sort="rand()" wraptag="ul" break="li" class="rslides">
<txp:image />
</txp:images>
<txp:article_custom time="any" limit="999">
<txp:posted />
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
<txp:else />
<!-- is individual article -->
<txp:article allowoverride="0">
<txp:if_custom_field name="bannerimagecategory">
<txp:images category='<txp:custom_field name="bannerimagecategory" />' wraptag="ul" class="rslides" break="li">
<txp:image />
</txp:images>
<txp:else />
<txp:image id="4" />
</txp:if_custom_field>
<txp:title />
<txp:body />
</txp:article>
<txp:article_custom section="events" wraptag="ul" break="li" time="future" label="Upcoming events" labeltag="h4">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
<txp:article_custom section="events" wraptag="ul" break="li" time="past" label="Past events" labeltag="h4">
<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>
</txp:if_article_list>
</txp:if_section>
TXP Builders – finely-crafted code, design and txp
Offline
Re: duplicate article on individual article page
Hi Julian,
Just to say thanks and I am studying your suggestion. I’ll of course post my results here
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: duplicate article on individual article page
Did you have any luck with that, Yiannis?
TXP Builders – finely-crafted code, design and txp
Offline
Re: duplicate article on individual article page
Hi Julian,
Not yet:(
This is for a new site I am working on. I am now thinking to start using different pages for each section, a technique I tried to avoid as I like having everything on the default page.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline