Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-04-10 07:06:31

ibadullah
New Member
From: Kabul, Afghanistan
Registered: 2017-09-16
Posts: 24

need publish date, source and article id

i need to have every article when i want to open it, it should have publish date, Source and article code or id under the title and then body text, for example:

my title
Published Date: 10/04/2019, Source: google, article id or code: 30
my body text

i will be very thankful if any one help me. thank you

Offline

#2 2019-04-10 07:37:43

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

Re: need publish date, source and article id

Assuming your articles are stored in Textpattern, you can use txp:title, txp:posted and txp:body, and you’ll probably want .

I don’t know what you mean by “source”, but if you mean the article url, then use txp:permlink or if you just want the stub or article ID number use txp:article_url_title and txp:article_id.

If with “source”, you are noting where you got the article from (or where the rest of the article is), create a custom field called “article_source” (or whatever you prefer), and store the source information along with every article in that field. Then use txp:custom_field to display that custom field. Using if_custom_field you can output that only if you have stored something there, and show perhaps the permalink if not filled out.

For example:

<txp:article_custom section="my-article-section" limit="999" wraptag="" break="">
<div class="article">
    <txp:title wraptag="h2" />
    Published date: <txp:posted format="%d/%m/%>" />
    Source: <txp:if_custom_field name="article_source" value="">
        <txp:permlink /> (ID: <txp:article_id />)
    <txp:else />
        <txp:custom_field name="article_source" />
    </txp:if_custom_field>
    <div class="article-content">
        <txp:body />
    </div>
</div>
</txp:article_custom>

… or something along those lines.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2019-04-10 18:02:04

ibadullah
New Member
From: Kabul, Afghanistan
Registered: 2017-09-16
Posts: 24

Re: need publish date, source and article id

Thank you very much jakob, exactly i want this thing, i will try what you guided.

Offline

Board footer

Powered by FluxBB