Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Struggling with article-display on a simple static webpage
Hi,
I created a simple static webpage. Idea: click a menu item, render one and only one article. My problem:
OK: when I follow a link from my menu, txp lists the single associated article (e.g. /category/example/)
Not-OK: when I’m in the root directory, txp lists ALL articles (at /)
Moreover, menu-item home should be link_to_home (/), not /category/home/ as it’s now.
What am I missing?
Thanks, Michael
- – -
That’s the way I organized the webpage:
ARTICLES
1) organized by Category 1 (=menu-related html-pages)
2) all articles assigned to Section articles
SECTION
1) default: Page default, Style default
2) articles: Page default, Style default, Name articles, Title Articles
PAGE
1) archive: empty
2) error_default: empty
3) default: see below
DEFAULT-PAGE (within <body> </body>)
1) NAVIGATION: <txp:output_form form=“menu” />
2) CONTENT: <txp:article form=“default” /> (no difference with <txp:output_form form=“default” />)
FORMS (type article)
1) DEFAULT
<div class=“entry-content”>
<txp:body />
</div>
2) MENU
<div class=“menu”>
<ul>
<txp:category_list wraptag=“li” categories=“home” />
…
<txp:category_list wraptag=“li” categories=“example” />
</ul>
</div>
Last edited by ms-spo (2012-03-06 13:00:06)
Offline
Re: Struggling with article-display on a simple static webpage
After reading context I turned on messy mode for a try. So my problem is related to context switch:
OK: when I follow a link from my menu, txp lists the single associated article (e.g. /category/example/) translates into /index.php?c=example (category context)
Not-OK: when I’m in the root directory, txp lists ALL articles (at /) translates into /index.php?s=articles (section context)
So: how to avoid the section context at root-entry OR how to switch it back to category context?
Thanks, Michael
Last edited by ms-spo (2012-03-06 15:14:52)
Offline
Re: Struggling with article-display on a simple static webpage
A way to catch the Not-Ok situation seems to be using
<txp:if_category name=”“ > … </<txp:if_category> (empty name string)
Now I only need to “redirect” or something like that.
Michael
Offline
#4 2012-03-07 08:30:41
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Struggling with article-display on a simple static webpage
If I understand you correctly, you have a category ‘home’ and you want only articles in that category to be displayed on the front page?
Change your menu like this:
<div class="menu">
<ul>
<li><txp:link_to_home>Home</txp:link_to_home>
<txp:category_list wraptag="li" categories="example,cat2,cat3,etcetera" />
</ul>
</div>
On the page, change <txp:article form=“default” />
to:
<txp:if_section>
<txp:article form="default" />
<txp:else />
<txp:if_category>
<txp:article form="default" />
<txp:else />
<txp:if_search>
<txp:article />
<txp:else />
<txp:article_custom category="home" />
</txp:if_search>
</txp:if_category>
</txp:if_section>
Offline
Re: Struggling with article-display on a simple static webpage
hi
to know if you are on home website you can use:
<txp:if_section name="">
your code for home page
</txp:if_section>
Offline
Re: Struggling with article-display on a simple static webpage
Hello Els,
thanks, you paved my way ;-)
I changed the menu according to your suggestion. What finally worked for the page-part is this:
<txp:if_section> <txp:article form="inhalt" /> <txp:else /> <txp:if_category> <txp:article form="inhalt" /> <txp:else /> <txp:if_search> <txp:article /> <txp:else /> <txp:article_custom id="2" form="inhalt" /> </txp:if_search> </txp:if_category> </txp:if_section>
together with form inhalt:
<tr> <td align="left" valign="top" > <txp:if_category name=""> <div class="entry-content"> <txp:article_custom category="home" /><txp:body /> </div> <txp:else /> <txp:article form="render_article" /> </txp:if_category> </td> </tr>
where form render_article simply is
<div class="entry-content"> <txp:body /> </div>
May be it’s still more complicated than necessary, but it works ;-)
Textpatterns ‘mechanis’ still is a mystery to me. What I find interesting is that
a) I had to change your suggestion <txp:article_custom category=“home” /> into <txp:article_custom id=“2” form=“inhalt” /> and
b) have to use the complicated structure in the <tr>-part
Els, thanks again. Great job.
Michael
Offline
Re: Struggling with article-display on a simple static webpage
Hello Dragondz,
thanks I used your suggestions. What I also like from the “Textpattern Solutions” book ist this, with php tuned on in the admin tab:
<txp:php> dmp($thispage['c']); dmp($thispage['grand_total']); dmp($thispage['numpages']); dmp($thispage['pg']); dmp($thispage['s']); dmp($thispage['total']); </txp:php>
Gave me some insight during debugging ;-)
Michael
Last edited by ms-spo (2012-03-07 19:06:19)
Offline