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

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

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,669
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 ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

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

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

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,395
Website GitHub Mastodon Twitter

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

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

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

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

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

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

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

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

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

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

#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

#12 2020-08-31 19:25:59

etc
Developer
Registered: 2010-11-11
Posts: 5,689
Website GitHub

Re: Tag for static section on homepage only

gu wrote #325689:

Super glad to share – but please advise how (make a github account? something else?)

We have a beta plugins site, but no (yet) centralized themes distribution mechanism. So anything you deem fit…

Offline

#13 2020-08-31 19:27:47

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

Re: Tag for static section on homepage only

> corrected a typo

I am sorry but I am back because the code solution has not only stopped the sticky page from displaying its text, but has also obstructed the search results from appearing.
Any input would be greatly appreciated, thank you again.

Last edited by gu (2020-08-31 19:28:55)


<!— space for hope —>

Offline

#14 2020-08-31 19:32:36

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

Re: Tag for static section on homepage only

I just wanted to add that the same problem happens when I use the code from the tutorial on the Write Panel (I don’t know how I did not see that page last night):

<txp:article form="myshortform" status="sticky" />
</txp:if_article_list>

<txp:article limit="5" />

<!— space for hope —>

Offline

#15 2020-08-31 23:09:26

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

Re: Tag for static section on homepage only

> still needing to edit for clarity…

Sadly I have to come back to this later… But I wonder if I understand what the root of the problem is.
[I didn’t immediately see the problem because while I tested pages when I put in the suggested code, I did not test the sticky page or the search box – which is where the problem is.]

My hunch that I may be beginning to understand something about the problem came when I was reading about how the txp design largely follows visitor actions. So, if this ‘recipe’ for the homepage is to include
1. a static section
2. the txp article list
3. search functions
4. category functions
the problem is that there is no “else”. It is all ‘yes’.
May I thank everyone for their kind help thus far! (And patience! I think that coding is good practice for communication in how it calls for precision – and in the case of txp, also brevity. I hope to learn from this.)

Last edited by gu (2020-08-31 23:24:16)


<!— space for hope —>

Offline

Board footer

Powered by FluxBB