Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-08-30 19:20:03

gu
Member
Registered: 2020-08-27
Posts: 44

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

#2 2020-08-31 01:32:37

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 2,110
Website

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 ?

Online

#3 2020-08-31 01:56:17

gu
Member
Registered: 2020-08-27
Posts: 44

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

#4 2020-08-31 04:34:55

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,269
Website

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.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#5 2020-08-31 08:56:43

etc
Developer
Registered: 2010-11-11
Posts: 3,855
Website

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: 44

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: 44

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

#8 2020-08-31 09:22:58

etc
Developer
Registered: 2010-11-11
Posts: 3,855
Website

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: 44

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

#10 2020-08-31 18:09:09

etc
Developer
Registered: 2010-11-11
Posts: 3,855
Website

Re: Tag for static section on homepage only

gu wrote #325687:

Indeed it worked! I am so excited to parse that now, thank you so much!!!

You are welcome! When your theme will be ready, please feel free to share, we lack ‘minimalistic’ examples here.

Offline

Board footer

Powered by FluxBB