Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2020-08-30 19:20:03
- gu
- Member
- Registered: 2020-08-27
- Posts: 59
Tag for static section on homepage only
Hi, after reading about custom, variables, etc. I thought that the following would allow the excerpt from an article to appear as a static section on the homepage only.
But it is not working.
Could anyone help correct it and explain what I am doing wrong? Thank you so much!
<txp:if_variable name=“homepage” value=“1”>
<txp:article_custom id=“4” />
</txp:if_variable name=“homepage” value=“1”>
<!— space for hope —>
Offline
Re: Tag for static section on homepage only
Can you clarify “it is not working”? Your post is a little vague…
also you have some mistake in your code above, it should be, at a minimum:
<txp:if_variable name="homepage" value="1">
<txp:article_custom id="4" />
</txp:if_variable>
For the rest… Is the variable set and returns true? A very simple test for this: insert some text right after the opening if_variable
and see if it comes out. Is the article assigned to a section that is set to display on the homepage?
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
#3 2020-08-31 01:56:17
- gu
- Member
- Registered: 2020-08-27
- Posts: 59
Re: Tag for static section on homepage only
Thank you for your patience.
My if_variable is whether (“if”) the page being displayed is the homepage or not.
If it is the homepage someone is visiting, I want the excerpt from id=“4” (a page that does exist) to be seen.
If it is not the homepage, I do not want id=“4” to be there.
I am putting this code on the default page that I am using for all pages. (It is meant to be a simple site.)
I hope that is clearer!
<!— space for hope —>
Offline
Re: Tag for static section on homepage only
Do Check Jakob’s post here.
<txp:if_section name="default">
<txp:if_article_list type="author, c, month, pg, q" not>
<txp:article_custom id=“4” form="" listform=""><txp:excerpt /></txp:article_custom>
</txp:if_article_list>
</txp:if_section>
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: Tag for static section on homepage only
gu wrote #325668:
My if_variable is whether (“if”) the page being displayed is the homepage or not.
If it is the homepage someone is visiting, I want the excerpt from id=“4” (a page that does exist) to be seen.
If it is not the homepage, I do not want id=“4” to be there.
I am putting this code on the default page that I am using for all pages. (It is meant to be a simple site.)
Is your page based on the theme supplied with txp? Otherwise, <txp:variable name="homepage" />
is not defined, unless you do it yourself.
Offline
#6 2020-08-31 08:57:16
- gu
- Member
- Registered: 2020-08-27
- Posts: 59
Re: Tag for static section on homepage only
Thank you so much for that helpful suggestion which I am now mulling over. It somehow suddenly helped me better understand the ‘learning about tags’ page.
Where I am still stumped: I get that ‘else’ tags can be nested (because the learning page says so), but what about something like ‘and’?
I would like the default homepage display to contain 5 most recent articles (which it currently does) AND always be preceded by the excerpt of one page, at the top.
Sadly, I need to put this aside for a few hours – but wanted to stop by to say thank you so much for this reply.
<!— space for hope —>
Offline
#7 2020-08-31 08:58:31
- gu
- Member
- Registered: 2020-08-27
- Posts: 59
Re: Tag for static section on homepage only
- edited because I did not properly copy and paste, sorry about that.
I just saw the above reply. I got the ‘zero’ install and then added the following beautiful code suggested by one of the txp tutorials:
<!-- static desc on homepage only-->
<txp:if_variable name=“homepage” value="1">
<txp:article_custom id="4" />
</txp:if_variable>
<txp:if_search>
<h2>
Search results
<q><txp:search_term /></q>
</h2>
</txp:if_search>
<txp:if_category>
<h2>
Articles in category
<q><txp:category /></q>
</h2>
</txp:if_category>
<txp:article />
Last edited by gu (2020-08-31 09:02:14)
<!— space for hope —>
Offline
Re: Tag for static section on homepage only
gu wrote #325679:
I got the ‘zero’ install and then added the following beautiful code suggested by one of the txp tutorials:
Since <txp:variable name="homepage" />
is not defined, this code will not work (as expected). Try
<!-- static desc on homepage only -->
<txp:if_article_list>
<!-- homepage -->
<txp:if_article_list not type>
<txp:article_custom id="4" />
<txp:else />
<txp:if_search>
<h2>
Search results
<q><txp:search_term /></q>
</h2>
</txp:if_search>
<txp:if_category>
<h2>
Articles in category
<q><txp:category /></q>
</h2>
</txp:if_category>
</txp:if_article_list>
</txp:if_article_list>
<txp:article />
You’d also better give article n°4 sticky
status, to exclude it from article listing.
Offline
#9 2020-08-31 17:59:49
- gu
- Member
- Registered: 2020-08-27
- Posts: 59
Re: Tag for static section on homepage only
Indeed it worked! I am so excited to parse that now, thank you so much!!!
<!— space for hope —>
Offline
Offline
#11 2020-08-31 19:03:57
- gu
- Member
- Registered: 2020-08-27
- Posts: 59
Re: Tag for static section on homepage only
> edited for clarity.
Super glad to share – but please advise how (make a github account? something else?)- It is bound to have mistakes (I am pretty sure the html labels are weird) – any advice on this reality is welcome
- Is it bad practice to make philosophical comments in the html?
- Can I thank people in the html?
- The site was achieved through the power of the txp : it is really, really simple (my inspiration was bettermotherfuckingwebsite and my needs for co-collaboration and integrating topics)
- It is almost done: just want to try to remove underlines and fix the static page.
Last edited by gu (2020-08-31 19:04:57)
<!— space for hope —>
Offline
Offline