Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2019-03-10 13:33:36

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,197
Website

Re: [solved] Dates in my <head>

Maybe we just need a couple new tags:

  • meta_published
  • meta_modified

:)


The text persuades, the *notes prove。

Offline

#12 2019-03-10 13:57:34

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,197
Website

Re: [solved] Dates in my <head>

Just to explain why I’m pursuing this…

As I detail my policies, that govern all Websites on the wion domain, and notably those policies in this case concerning copyrights, I’ve become more aware from research that depending on the kind of license a given ‘Material’ has, it influences whether one cites a source in the course of ‘fair dealing’ or give attribution. The two are not the same, though it really depends what the context of use is.

In the case of citing — which is a specific ‘exception’ of use in French law to which the author can not interfere (not a ‘fair dealing’ exactly, but similar) — whether as a note or biblio entry or both, not all online resources have the same reference structure. At least not according to the Oxford style, which is what I use, but Chicago has a plethora of reference structure differences too. These are just some of the different formats in the OSM:

  • Online article
  • Online reference (e.g. Encyclopedia Brittanica)
  • Online interview
  • Wiki page (e.g. Wikimedia)
  • Blog post
  • News article (e.g. via The Guardian)
  • Journal article (i.e. academic journal)

Oddly, among all the examples given, there is no specific reference for:

  • ‘online periodical’ (e.g. a magazine article)
  • ‘general webpage’ (e.g. About, History, Policies…)

So one has to fake it a bit by pulling from the closest options. In the case of a general webpage — though static, is nevertheless revised occasionally — where there is usually no specific author or publish date on the top, it’s convenient to add that info as metadata. Then someone can still find what they need to create a proper reference and satisfy legal obligations to cite source copyrighted information correctly, for example

Wion, Destry, ‘Policies’, wion.com (last modified 10 March 2019), https://wion.com/policies, accessed 23 March 2019.

In these cases the ‘last modified’ date are somewhat important when the information is of a critical nature (e.g. Policies) and subject to change through time.


The text persuades, the *notes prove。

Offline

#13 2019-03-10 14:21:19

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,461
Website

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.

etc’s suggestion looks good. Can you clarify in what context that doesn’t work (an article, a list page? Perhaps also try and see if you get any output from the tags when not wrapped in the variable. You should at least be getting output on an individual article page.


TXP Builders – finely-crafted code, design and txp

Offline

#14 2019-03-10 14:33:53

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,197
Website

Re: [solved] Dates in my <head>

jakob wrote #316964:

Can you clarify in what context that doesn’t work . . . an article, a list page?

Like a lot of people, I’m guessing, I have my templates parsed into pieces that get joined up on render. This particular piece is in the tmpl_meta, itself called inside the tmpl_opener piece that’s common to all pages and sections.

For this particular site, I have a 1:1 section:page relation because the site is so small.

Nevertheless the top-most (e.g. the meta stuff) and bottom-most parts of the templates are common across them all.

At the body level, I have only two different article forms: one for ‘static’ pages, like I’m testing on now, and one for notes (somewhat equivalent to a blog). The latter shows the author and post date, so it’s not relevant in this case… Though now that I think of it, maybe that’s a conflict against the static pages sharing the same meta form.

Make sense? Maybe I need two different meta forms and a conditional to juggle them? Though I don’t see why I can’t get this work on the common form, but I’m hardly one to be confident about anything I’m doing these days.


The text persuades, the *notes prove。

Offline

#15 2019-03-10 15:13:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,665
Website

Re: [solved] Dates in my <head>

The URL should give you an indicator. Assuming you’re using /section/title permlinks then if your URL is just /section, Txp will be in article list (a.k.a. landing page) context, regardless of whether you have told your <txp:article /> tag to output just one article and to display its body content or whatever.

This is often the case on contact pages where you have one article in the Section. On a typical (fairly new out of the box) site, visiting example.org/contact may render your ‘article-list’ Form, requiring you to click on the <h1> tag to visit the actual article (perhaps at example.org/contact/get-in-touch).

To get round this, I sometimes have a “one-article” Form that I use on Sections that only have one article. This Form is called as follows:

<txp:if_section name="list, of, sections, with, one, article">
    <txp:article form="one-article" limit="1" />
<txp:else />
    <txp:article />
</txp:if_section>

The one-article Form is coded to display the full body copy text, so even at the /contact landing page, visitors see everything as if the URL represents an individual article. Further, I remove the anchor on the heading so the ‘real’ article URL is masked from search engines and therefore doesn’t incur the wrath of duplicate content.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#16 2019-03-10 17:56:25

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

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.


etc_[ query | search | pagination | date | tree | cache ]

Offline

#17 2019-03-10 18:04:54

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

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>

etc_[ query | search | pagination | date | tree | cache ]

Offline

#18 2019-03-10 23:23:39

Destry
Moderator
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,197
Website

Re: [solved] Dates in my <head>

Bloke wrote #316967:

The one-article Form is coded to display the full body copy text, so even at the /contact landing 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.


The text persuades, the *notes prove。

Offline

#19 2019-03-11 09:38:28

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

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?


etc_[ query | search | pagination | date | tree | cache ]

Offline

Board footer

Powered by FluxBB