Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-04-18 09:46:38

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

How do I link directly to an article?

I’m using my own navigation bar instead of the TXP navigation tree. I’ve created some article pages that I’d like to link directly. But every time the article is modified the URL changes. Example: I have an article on Food for the Homeless which creates the following URL: http://www.mywebsite.org/services/10/Food+For+The+Homeless. However, I’d like to be able to have a fixed URL, something like: http://www.mywebsite.org/services/Food+For+The+Homeless OR http://www.mywebsite.org/Food+For+The+Homeless. Is this possible?


Living the Location-Independent Life: www.NuNomad.com

Offline

#2 2010-04-18 10:00:08

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,942
Website GitHub

Re: How do I link directly to an article?

Try changing your Permlink mode in Admin->Basic Prefs to something other than section/id/title. Curious why your URL would change when the article is edited, but that pref should sort you out anyway.


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

#3 2010-04-18 10:01:38

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: How do I link directly to an article?

Go to Admin > Preferences and look for “Permanent link mode”. That will show you the URL options.

Offline

#4 2010-04-20 07:31:03

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: How do I link directly to an article?

Thank you Blok and Jonathan for replying!

The advice to change my Permanent Link mode to something other than section/id/title did remove the arbitrary numbering of the article (when I used the mode: section/title). However, the article when clicked within the navigation tree will not show. I think it has to do with my article tags, but I’m a rookie at this and I’ve yet to figure out my problem. Maybe someone can spot the problem?

What I’m trying to achieve: I’m trying to create a template page for some static content within the same category. I made a page (Services) which works with the Section of the same name. An overview Article of services (Client Services) was created, using the Sticky status option and it points to the section Services. (The URL-only-title is: client-services). All other articles (2 of them) within the Services category are live but are not “sticky”.

On my “Services” Page, I have this tag:
<txp:article status=“sticky” form=“static_text” limit=“1” />

The static_text Form have these attributes: <div class=“staticentry”><h1><txp:title /> </h1> <txp:body /></div>

So, when I click the Services link (i.e.: http://www.dotorgwebworks.org/example.dev/services/) the overview of “Client Services” as intended (which is a sticky page.) In the navigation tree are the other Articles under the Services section. When I click “Other Great Services” (i.e.: http://www.dotorgwebworks.org/example.dev/services/services-other) the article does not appear. I suspect it has to do with my “Sticky” article status on the Page TXP tag?

Help :-|


Living the Location-Independent Life: www.NuNomad.com

Offline

#5 2010-04-20 18:21:38

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: How do I link directly to an article?

laptophobo wrote:

I suspect it has to do with my “Sticky” article status on the Page TXP tag?

Yes, your tag <txp:article status="sticky" form="static_text" limit="1" /> can never display a ‘live’ article. You can add <txp:article form="static_text" limit="1" />, this will never display a ‘sticky’ article, so having both tags will never give you more than one article, either ‘sticky’ or ‘live’.

Offline

#6 2010-04-21 06:39:07

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: How do I link directly to an article?

Okay, combining the two worked. Thanks so much for your help.


Living the Location-Independent Life: www.NuNomad.com

Offline

#7 2010-04-21 08:38:16

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: How do I link directly to an article?

Oops. I spoke too soon. Combining the two tags produced a Sticky Article and one of the Live Articles on the page. Here’s my tags:
<txp:article status=“sticky” form=“static_text” limit=“1” />
<txp:article form=“static_text” limit=“1” />

So, am I doing something wrong here? (I’m trying to have only 1 Article per page. The “sticky” would serve as the default article on this Page and Section.

Help :-\


Living the Location-Independent Life: www.NuNomad.com

Offline

#8 2010-04-21 16:48:22

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: How do I link directly to an article?

laptophobo wrote:

Oops. I spoke too soon. Combining the two tags produced a Sticky Article and one of the Live Articles on the page.

Ah, I assumed you were referring to an individual article page only. That code doesn’t really work on an article list page.

(I’m trying to have only 1 Article per page. The “sticky” would serve as the default article on this Page and Section.

Not sure if I understand you correctly, does this do what you want?

<txp:if_article_list>
<txp:article status="sticky" form="static_text" limit="1" />
// and a link to the first live article, e.g.:
<a href="<txp:permlink id='<txp:article limit="1"><txp:article_id /></txp:article>'>your link text</a>
<txp:else />
<txp:article form="static_text" />
// add the next and prev tags for navigation here
</txp:if_article_list>

If you are sorting your articles other than ‘posted desc’ you’ll need to add the sort attribute to the article tag inside the id attribute.

Offline

#9 2010-04-22 03:40:51

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: How do I link directly to an article?

Thanks again, Els, for helping me with this problem! The custom tag you provided me did not work since I was at a loss to modify it. :-} However, I did play with it a bit and came up with this:

<txp:if_article_list>
<txp:article status=“sticky” form=“static_text” limit=“1” />

<txp:else />
<txp:article form=“static_text” />

</txp:if_article_list>

This seems to work!

To recap what it is I’m doing (for the benefit of other Forum viewers) is to create a landing page for all articles within my Services section. But only 1 article should be on the Services page at a time. And, the “Sticky” article will be the default article (by itself) when one clicks the Services tab. Within the TXP navigation tree, under the Services link, are a few sub-links that are articles within the Services section. When one clicks the sub-link, that article replaces the default “Sticky” article.

Thanks again for your help. :-}

Last edited by laptophobo (2010-04-22 03:54:07)


Living the Location-Independent Life: www.NuNomad.com

Offline

Board footer

Powered by FluxBB