Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How display article from another section but with URL from current sec
I know it sounds little bit wierd, but here is the thing I want. I have article in section “projects” like domain.com/projects/title-of-project
Now I would like to display this article in another section but in detail, so not in article list, but as individual article, eg.: domain.com/references/title-of-project
I know it is against rules, because txp looks for section and ID in url scheme section/title and that is why it throws 404 because this ID does not exist in this section.
In article listing for specific section is not problem to use txp functions to display articles from different section where article_custom is short for it:
<txp:php>
$rs = safe_rows_start('*, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod', 'textpattern', '(section="projekty" AND custom_5="Ano") OR section="realizace-staveb" ORDER BY custom_4 desc');
if ($rs) {
$articles = array();
while($a = nextRow($rs)) {
populateArticleData($a);
global $thisarticle;
$articles[] = parse_form('reference-vypis');
}
echo doWrap($articles, '', '');
}
</txp:php>
In page form for individual article I’ve got this:
<txp:if_individual_article>
<txp:php>
HERE I NEED HELP
</txp:php>
</txp:if_individual_article>
How to call article with actual url – url_title (which belongs to another section) and avoid 404? Does anybody know? Is it possible?
Last edited by beztak (2009-04-06 20:03:08)
Job: Plugo – tvorba eshopu
Projects: Czech free fonts
Offline
Re: How display article from another section but with URL from current sec
I found an easy solution, now I can have one article in unlimited sections with clean URL. It’s absolutly awesome, I edited few lines in publish.php from this:
case 'section_title':
if (empty($u2)) {
$out['s'] = (ckEx('section',$u1)) ? $u1 : '';
$is_404 = empty($out['s']);
}
else {
$rs = lookupByTitleSection($u2,$u1);
$out['id'] = @$rs['ID'];
$out['s'] = @$rs['Section'];
$is_404 = (empty($out['s']) or empty($out['id']));
}
break;
to this godlike code:
case 'section_title':
if (empty($u2)) {
$out['s'] = (ckEx('section',$u1)) ? $u1 : '';
$is_404 = empty($out['s']);
}
else {
$rs = lookupByTitleSection($u2,$u1);
$out['id'] = @$rs['ID'];
$out['s'] = @$rs['Section'];
if (empty($out['id'])){
$rs = lookupByTitle($u2);
$out['id'] = @$rs['ID'];
$out['s'] = ckEx('section', $u1);
}
$is_404 = (empty($out['s']) or empty($out['id']));
}
break;
So if there is no ID in particular section start to lookup by title (url_title) and push up current section from URL. This works for url scheme section_title and of course if url_title is unique. Hope this will help to other people. It also works with MLP ;)
Last edited by beztak (2009-04-06 20:18:24)
Job: Plugo – tvorba eshopu
Projects: Czech free fonts
Offline
Re: How display article from another section but with URL from current sec
now I can have one article in unlimited sections with clean URL
Interesting.
Would like to read why you needed this feature.
Now that there is rel="canonical"
there isn’t too much worry about duplicated content on the same site, but why would you want to have your content not just twice but “unlimited times” in different sections?
It could be fine for having many “related” contents in just one article, divided by if_section
tags. not too hard for clients to learn…
Offline
Re: How display article from another section but with URL from current sec
maniqui wrote:
Interesting.
Would like to read why you needed this feature.
Now that there isrel="canonical"
there isn’t too much worry about duplicated content on the same site, but why would you want to have your content not just twice but “unlimited times” in different sections?
In fact I need to show one article only in two sections (but changed code can push article in unlimited section just according to URL) because meaing of article is the same – two sections are “projects” and “realization”. Client can only do some project but this can be realized or not. So one article can belongs in two logical sections. Plus if they built something they didn’t projected this can be pushed only to section “realization”. Thanks custom_field I told system if “project” was also realized, if yes display it on “realization” section too.
This can be very helpful on every page with client references – e.g. webdesigners portfolio – one reference can be displayed in graphics, e-shop, xhtml coding.
Job: Plugo – tvorba eshopu
Projects: Czech free fonts
Offline