Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-02-12 08:47:25

th3lonius
Member
From: Iowa City, IA
Registered: 2010-02-09
Posts: 67
Website

Query articles with the same title

On my film essay website all of the reviews use the exact title of the film as <txp:title />. So it was inevitable that with our multi-authored platform we would run in to multiple reviews for the same film. I currently get around this by manually appending a digit to the end of the URL title (e.g. /the-social-network, /the-social-network2, etc.). Does anyone have a more elegant solution?

Really this isn’t much of an issue. What I really need help with is constructing a database query (with smd_query or something) that outputs some code if more than one article has the same title. Instead of a single link (film title and screen capture) that is used in most cases, if a film has more than one review I need to output the title of the film with separate links for each author who has essayed it.

The following should work fine in an individual article context:

<txp:smd_query query="SELECT url_title,title,author FROM textpattern WHERE title='<txp:title />' AND status=4 AND id <> '?thisid' ORDER BY author asc" label="Also essayed by:" labeltag="div" wraptag="ul" class="unorderedList uppercase"> <li><a href="<txp:site_url />reviews/{url_title}">{title} by {author}</a></li> </txp:smd_query>

But I need to be able to do this on my homepage which displays a list of the most recent articles. It’s crucial I work out a solution to this soon, because to coincide with the Academy Awards we’re covering all 10 best picture nominees, and nearly every one of them will have multiple reviews from different contributors with ‘The Social Network’ likely having 4!

If anyone needs to visualize what I’m going for the website is the one associated with my <txp: /> forum account off to the left.

Thanks!

Offline

#2 2011-05-15 10:46:45

alexandra
Member
From: Cologne, Germany
Registered: 2004-04-02
Posts: 1,370

Re: Query articles with the same title

Hi,

i have a similar question: a client of mine (she is working as talent coach, german) wants to add some of her articles translated into english. Now we have some titles which are identical as we use those words in german AND in english f. e. Talentmanagement. Her site URL structure is: home/section/title

Now i run into the problem having twice the same title which is “forbidden” in TXP. (By the way: why at all?)

She wants to have URLs like this: home/en/talentmanagement AND home/talentmanagement/talentmanagement for SEO reasons.

Anybody an idea how i can achieve that without workarounds and categories etc.. ?
(site runs on txp 4.2.0)

Last edited by alexandra (2011-05-15 10:49:43)

Offline

#3 2011-05-15 13:24:30

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

Re: Query articles with the same title

th3lonius

Missed this first time, sorry, and it’s probably a bit late now but could you use section/id/title permlinks? I believe TXP will still issue a warning if you save a 2nd article with the same title but the URL will at least be unique.

This also makes it easy(ier) to run a query because the url titles are identical.

You can still do code like the one you supplied on the front page if you do it inside a standard article / article_custom tag container, with results sorted by Posted desc. Inside an article container, article context is triggered so you can match the ‘current’ article as if you were viewing that individual article. The downside is that the number of queries will increase but there’s not much you can do about it unless you construct the entire query in one hit.

alexandra

I have no idea why it’s “forbidden” in TXP. It’s not actually forbidden, but that warning pops up anyway. If you can’t switch to section/id/title, then I would guess the gbp_permanent_links plugin will be able to help you achieve that structure without much hassle. I’m not the world’s greatest user of it though so you’re better of asking in the forum’s thread.


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

Board footer

Powered by FluxBB