Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-06-24 10:44:19

ricetxp
Member
From: London, UK
Registered: 2005-05-24
Posts: 89
Website

same URL-only title and article status

I have two articles with the same URL-only title. One is live, the other is set to go live at a future date. The one that is live will expire when the second one goes live. However, only the future article gets displayed. Using <txp:article status="live" /> has no effect. Help would be much appreciated.

Offline

#2 2010-06-24 12:31:29

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: same URL-only title and article status

If you’re using one of the no-ID permanent link modes (e.g. /section/title) then I think you will always get the first article (of the two with the same title) in the database. I’m guessing this is the one with the lower ID number. And I don’t think you’d solve the problem by switching the articles, because after the expiration date you would then have the opposite problem.


Code is topiary

Offline

#3 2010-06-24 13:51:12

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: same URL-only title and article status

Isn’t this a bug then?


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

#4 2010-06-24 17:36:01

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: same URL-only title and article status

I don’t think so. If you opt to use the /section/title or /title URL scheme, you need to use distinct URL-only titles. Stands to reason.


Code is topiary

Offline

#5 2010-06-24 20:06:35

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

Re: same URL-only title and article status

Does it work if you explicitly add time="past"?

Offline

#6 2010-06-24 20:55:16

JanDW
Plugin Author
From: Providence, RI, USA
Registered: 2008-07-18
Posts: 327
Website

Re: same URL-only title and article status

Stands to reason.

Ah, somehow I missed the ‘same URI-title’ thing…

Just an idea: since you can use txp tags in an article I suppose you could pull in that article (and its replacement) with article_custom from another section (maybe just created for these articles) so that you can have two different URI-titles ?

Last edited by JanDW (2010-06-24 20:56:30)


TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX

Offline

#7 2010-06-25 12:21:54

ricetxp
Member
From: London, UK
Registered: 2005-05-24
Posts: 89
Website

Re: same URL-only title and article status

I take the point about same url_title and IDs not being a bug. However, it seems a bit flawed if publish dates are explicity ignored. Using time="past" has no effect. I’ll try the article_custom method suggest by JanDW.

Offline

#8 2010-06-25 12:34:17

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

Re: same URL-only title and article status

ricetxp wrote:

One is live, the other is set to go live at a future date. The one that is live will expire when the second one goes live.

Does this mean that the article that has the future date actually has a status other than ‘live’?

Offline

#9 2010-06-25 14:16:10

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: same URL-only title and article status

ricetxp:

You may want to take advantage of txp:if_expired, and use it directly in your article body.

<txp:if_expired>
future content, blabla
<txp:else />
current content
</txp:if_expired>

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#10 2010-06-25 16:11:21

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: same URL-only title and article status

@Julián: Nice idea but my guess is that it still won’t work. The lookupByTitle() function (see publish.php) simply looks for the first matching article by url-only title that has live status. If there are two articles with the same title I expect it will always return the same one.

@Edward: I don’t disagree that this is a flaw (although I would use the word “limitation” instead). Simplest solution is to use IDs in the URL. I can well understand that this is not ideal, especially if this is an established site. Other workarounds are possible; what is best (or least bad) would depend on the exact requirements and characteristics: are there many articles you want to treat this way, if so is there an easy way to distinguish these from other articles, etc.


Code is topiary

Offline

#11 2010-06-25 16:34:32

ricetxp
Member
From: London, UK
Registered: 2005-05-24
Posts: 89
Website

Re: same URL-only title and article status

At present it’s a one-off. I’ve decided to do the change over manually. I’ve given the future article (status="live") a different url_title for the time being. On the day of change over, I’ll manually change the url_title and hide the expired article.

The article was for a competition. The idea is to promote it before it goes live. Hence the need to keep the same url. There’s quite bit of competition logic which isn’t on the article itself, but is called in with custom_field values, so it makes it difficult to try and use a different method.

I love textpattern, but I guess I was simply expecting not to see articles that were set with a future publish date to be live on the site, regardless of other overriding logic.

Offline

#12 2010-06-25 16:39:31

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: same URL-only title and article status

Jeff: my idea implied discarding one of the two same URL-only title articles, and do all the switch inside the article body, with the help of txp:if_expired.

Regarding a solution for the original setup (two articles, both set to “live”, one is currently “past” and set to expire, the other is just set to a “future” date, both sharing the same URL-only title): although I don’t know exactly how the inner cogs of TXP works (jsoo gave some insights on this thread about this), I wonder if this couldn’t just be solved by a clever/basic usage of txp:article or txp:article_custom and its attributes.

Mmmm… now that I think a bit more about this, I’m now assuming this is not a problem in an article list context, but on the individual article (aka permalink) context, correct?
I mean, on article list context it may or may not be issues for having two articles with the same URL-only title, but when on individual article, TXP necessarily fetchs it from database using the lookupByTitle, as Jeff mentioned.

As Jeff clearly stated, the best solution will depend on the exact requirements. If this is just an edge case, you could just do some article ID hardcoding somewhere in your templates to solve this easily.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB