Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [solved] Dates in my <head>
Destry wrote #316960:
If I try using that snippet exactly, I get this output:
<meta name="published" content="">...Empty content attribute.
If you are on 4.7.2+, the only reason I can see is that you have no live articles on the concerned landing page. You can try to append status="sticky" attribute to <txp:article /> if the dates are pulled from there. In this case pageby="0" is not needed.
Offline
Re: [solved] Dates in my <head>
There is also a more efficient way, sparing a db query. Put this in the meta generating form:
<txp:hide process="2">
<meta name="published" content='<txp:variable name="posted" />'>
</txp:hide>
and the variable definition in the article form outputting the “main” article:
<txp:if_first_article>
<txp:variable name="posted" value='<txp:posted />' />
</txp:if_first_article>
Offline
Re: [solved] Dates in my <head>
Bloke wrote #316967:
The
one-articleForm is coded to display the full body copy text, so even at the/contactlanding page, visitors see everything as if the URL represents an individual article.
Thanks for that perspective. It helped. I actually had something overall similar, I think, but my body snippet was this:
<txp:if_article_list>
<txp:article status="sticky" form="simple_article" />
<txp:else />
<txp:article status="live" form="simple_article" />
</txp:if_article_list>
I don’t know where I came up with that, exactly. I think it might have been something I reused from out-of-box?
Anyway, I adjusted to your example using if_section and changing limit="1" to status="sticky" and it seems to work fine:
<txp:if_section name="about, policies, contact, guide">
<txp:article form="article_simple" status="sticky" />
<txp:else />
<txp:article />
</txp:if_section>
etc wrote #316973:
the only reason I can see is that you have no live articles on the concerned landing page. You can try to append
status="sticky"attribute to<txp:article />if the dates are pulled from there.
And making that one little change to status="sticky" did the trick. The missing key. And I dropped limit="1". I assume that’s okay. It seems to work, since sticky is in the driver’s seat.
But, I want both posted and modified, so I’m doubling up on the markup now:
<txp:variable name="posted" escape="trim">
<txp:if_article_list>
<txp:article status="sticky"><txp:posted /></txp:article>
<txp:else />
<txp:posted />
</txp:if_article_list>
</txp:variable>
<txp:variable name="modified" escape="trim">
<txp:if_article_list>
<txp:article status="sticky"><txp:modified /></txp:article>
<txp:else />
<txp:modified />
</txp:if_article_list>
</txp:variable>
<meta name="published" content="<txp:variable name="posted" />">
<meta name="modified" content="<txp:variable name="modified" />">
That works, but I still wonder if something like this could be cooked up in the future, where each tag could take a string="" attribute for custom date formats:
<txp:meta_publish />
<txp:meta_modified />
But I’m sure it’s more complex than that.
I’m happy regardless. Thanks, all. I appreciate your patience/diligence.
Offline
Re: [solved] Dates in my <head>
Glad you got it solved. I would just define both dates in one <txp:article /> call:
<txp:if_article_list>
<txp:article status="sticky" limit="1">
<txp:variable name="posted" value='<txp:posted />' />
<txp:variable name="modified" value='<txp:modified />' />
</txp:article>
<txp:else />
<txp:variable name="posted" value='<txp:posted />' />
<txp:variable name="modified" value='<txp:modified />' />
</txp:if_article_list>
Destry wrote #316979:
That works, but I still wonder if something like this could be cooked up in the future, where each tag could take a
string=""attribute for custom date formats:
<txp:meta_publish />...But I’m sure it’s more complex than that.
Yep, it looks complicated for article lists where we have to decide where the dates come from: live/sticky articles? which ones?
Offline