Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-02-28 10:20:06

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

"latest article" tag

Is there a navigation tag for “latest article” ?

I’ve had a search and can’t find one. Possibly it’s got a different name; or maybe the semantics are more complicated.

Anyway – I can’t find the answer.

Application: I want to change the “Home” link at my site to latest article.

At the moment – it calls for the site URL, which in turn loads any random article, which doesn’t make sense.

Offline

#2 2016-02-28 11:01:02

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

Re: "latest article" tag

Hi James, I guess that there are many ways to achieve this

  • <txp:recent_articles limit="1" wraptag="" break="" />
  • <txp:article limit="1"><a href="<txp:permlink />"><txp:title /></a></txp:article>
  • as above but using <txp:article_custom>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2016-02-28 12:24:43

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: "latest article" tag

Thanks. Tried this and it doesn’t work:

<txp:recent_articles limit="1" wraptag="" break="" /> class="current"</txp:if_section>><a href="/" title="">Home</a>/li>

The code I’m using for all the top nav links in the header is this:

<txp:if_section name=""> class="current"</txp:if_section>><a href="/" title="">Home</a>

- so I’m not sure how to implement what you’re saying.

Seems pretty simple – is it possible you could just post the code that I need to use, in full, so it will work?

Offline

#4 2016-02-28 17:02:04

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

Re: "latest article" tag

Hi James,

Is the code below what you need?

<txp:article_custom limit="1"><a <txp:if_article_id='<txp:article_id />'> class="current"</txp:if_article_id> href="<txp:permlink />"><txp:title /></a></txp:article_custom>

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 2016-02-28 19:32:57

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: "latest article" tag

Probably ;-)

But where do I insert the “Home” to build the link?

- which I will change to “Latest”.

Offline

#6 2016-02-29 06:39:23

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

Re: "latest article" tag

Could you post the whole of your menu code here?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2016-02-29 19:56:38

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: "latest article" tag

Sure, here it is. I’ve cut out some irrelevant code:

<link rel="home" href="/" title="Home" />
<link rel="author" href="/contact" title="Contact the author" />

<link rel="alternate" type="application/rss+xml" title="RSS 0.92" href="/rss" />
<link rel="alternate" type="application/atom+xml" title="Atom 1.0" href="/atom" />

<link rel="Shortcut Icon" type="image/x-icon" href="/favicon.ico" />

<txp:if_section name="story"><txp:kml_flashembed_js /></txp:if_section>



</head>

<body>

<div id="page">

	<div id="header">

		<ul id="nav-list">

			<li<txp:if_section name=""> class="current"</txp:if_section>><a href="/" title="">Home</a></li>

			<li<txp:if_section name="photos"> class="current"</txp:if_section>><a href="/photos/<txp:article_custom section="photos" form="latest_link" limit="1" />" title="">Archive</a></li>



<li<txp:if_section 
name="video"> 
class="current"</txp:if_section>><a href="/video" title="">Video</a></li>

<li<txp:if_section 
name="words"> 
class="current"</txp:if_section>><a href="/words" title="">Words</a></li>


			<li<txp:if_section name="contact"> class="current"</txp:if_section>><a href="/contact" title="">About</a></li>

<li<txp:if_section name="rss"> class="current"</txp:if_section>><a href="/rss" title="">RSS</a></li>

		</ul>

		<div class="clear">&nbsp;</div>

	</div>


	<div id="wrapper">
<br>

Offline

#8 2016-02-29 20:45:33

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: "latest article" tag

It’s not the button that does the function but the page that it calls up, so all you will need to change on the navigation is the wording from “Home” to “Latest”.

Assuming you’d like the newest article in the “photos” section to show in full when you click on “home” (or “latest”), what you could do is:

  1. In the “Presentation > Pages” panel, duplicate the page template you use for the “photos” section and give it a new name (take care not to overwrite your photos or default page template).
  2. Look for the relevant txp:article tag you have there in the template, and see what form it uses to display an article
  3. Replace that tag with Yiannis’ suggestion above using the same form="your-form" (not listform if it is there). It might be something like this:
    <txp:article_custom section="photos" limit="1" form="your-single-photo-form-name" />
    If you wish, you can post that part of your page template here in the form and we can advise.
  4. In the “Presentation > Sections” panel, click on default and under “use template” set the new page template.

That should give you this view except it will be the newest one.


TXP Builders – finely-crafted code, design and txp

Offline

#9 2016-03-01 17:13:44

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

Re: "latest article" tag

Hi James,

I was wondering if you sorted it out after Julian’s post or if you needed more help.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#10 2016-03-01 20:16:39

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: "latest article" tag

Many thanks…just working on it……

Offline

#11 2016-03-01 20:26:36

jameslomax
Member
From: UK
Registered: 2005-05-09
Posts: 448
Website

Re: "latest article" tag

Is it this I should modify:

<txp:if_individual_article>

<txp:article form=“photo_single” />

To become this:

<txp:if_individual_article>

<txp:article_custom limit=“1”><a <txp:if_article_id=’<txp:article_id />’> class=“current”</txp:if_article_id> href=”<txp:permlink />”><txp:title /></a></txp:article_custom>

- I can’t comprehend this code and what it does, but i can of course follow instructions.

Offline

#12 2016-03-01 21:31:55

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: "latest article" tag

No, that code doesn’t look like the right code to replace.

To be on the safe side, make a copy of your template somewhere (e.g. in a text document) and perhaps post us as much of the content part of the home and photos page templates as you can and tell us which page template you have it from. You may need to look in the ‘Presentation > Sections’ panel to see which page template is used for the home and photos sections. If you use bc.. {posted code} then blank line, then p. and the rest of your forum post… to post it, it will display properly here in the forum.

If I have understood you correctly, you want the most recent single photo and its text to show on the home page (in txp the section called default). The home page is a landing page, which in txp-speak is an article list page. It’s url does not point to a specific item of content – i.e. an individual article – so that if-statement you posted will not help you.

My guess is that you want this on the template you have for the home/default section:

<txp:article_custom section="photos" limit="1" form="photo_single" />

That says when this template is called up, output one article only from the photos section using the photo_single display form. By default it sorts by posted date descending, so the first article it finds will be the most recent one. We’re using article_custom here to just source from the photos section, i.e. to override default behaviour, which is to post the last items from the sections that have been designated as being allowed to show on the homepage. This code goes in the content area area of the page template used to show the home/default section, not in the menu navigation. It should not be in a section with if_individual_article, because we are on a landing page. If you post us your page template, we can say more specifically.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB