Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-12-19 00:31:20

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Article from a section in place of an article in another section

Hello there, hope you are all ok.

I have this question that probably falls outside the typical Txp navigation logic.

Is it possible to display an article from a section in place of an article in another section ?

In other words:

I saved my article in Section: cats.

And I want to display it as well in a section called: dogs.

Apparently simple.

Last edited by hablablow (2010-12-19 00:31:51)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#2 2010-12-19 00:39:01

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

Re: Article from a section in place of an article in another section

With article_custom you can display any article anywhere. How you would implement this depends on what you mean by “in place of”. What situations do you need this substitution?


Code is topiary

Offline

#3 2010-12-19 00:43:05

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Article from a section in place of an article in another section

Hi Jeff.

Precisely I have this url:

mysite.com/cats/fritz

and when I go to:

mysite.com/dogs/fritz

The article called “fritz” will not show up.

I would like to have the same article “fritz” displayed in section “dogs” although I saved this article only in section “cats” in the article tab.

Tried to output the fritz article in the dogs section with <txp:article_custom section=“cats” limit=“1” /> but it outputs nothing.

Last edited by hablablow (2010-12-19 00:54:29)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#4 2010-12-19 01:03:14

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

Re: Article from a section in place of an article in another section

hablablow wrote:

Tried to output the fritz article in the dogs section with <txp:article_custom section=“cats” limit=“1” /> but it outputs nothing.

That is because article_custom doesn’t display individual articles, only article lists.

You can create an article ‘Fritz’ in section dogs, and in the body of that article put something like this:

<txp:article_custom id="xxx">
   <txp:body />
</txp:article_custom>

If you are going to need this for more than one article, you could use a custom field, in which you put the article id of the original article. Then replace id="xxx" with id='<txp:custom_field name="yourcf" />'.
You will still need to create the extra article in the other section though.

Offline

#5 2010-12-19 01:07:31

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

Re: Article from a section in place of an article in another section

I did a quick test of equivalent code and it worked. Better post a tag trace.


Code is topiary

Offline

#6 2010-12-19 01:08:42

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Article from a section in place of an article in another section

Thank you for your answer folks. I’ll digg deeper and return as soon as I have something new.


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#7 2010-12-19 13:22:20

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Article from a section in place of an article in another section

What code did you use Jeff to achieve it ?


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#8 2010-12-19 13:55:25

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

Re: Article from a section in place of an article in another section

hablablow wrote:

What code did you use Jeff to achieve it ?

<txp:article_custom section="cats" limit="1">
<txp:title />
</txp:article_custom>

I put that into the page template for section “dogs”. (Substituted existing section names for “dogs” and “cats”.) Worked as expected.


Code is topiary

Offline

#9 2010-12-19 20:41:31

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Article from a section in place of an article in another section

Jeff, thanks for the snippet.

When you navigate to both urls:

site.com/dogs/fritz
site.com/cats/fritz

You have any output on both ?

Because here one url outputs the article as expected, the one section in which the article was saved.
And of course on the other page, when I go down the tree until the article, it outputs nothing…
In fact it outputs a blank page, url is not known anywhere since the article belongs to the other section…

To summarize: is it possible to post an article in many sections ? Or, another solution might be to have a section behaving like the default home page…
Or use the <txp:article_related /> tag to output content from the same category but in another section ?

Or by using a plugin ?

Sorry folks for firing so much questions-directions but I really don’t know how to solve that one…

Last edited by hablablow (2010-12-19 20:51:07)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#10 2010-12-19 22:11:15

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

Re: Article from a section in place of an article in another section

I assume you are using /section/title for permanent link mode. site.com/dogs/fritz, as such, does not exist. Hence the blank page (really should be a 404). You cannot post an article in more than one section. You can make it appear on any (valid) page.

I suppose you could post a dummy article for dogs/fritz. Then use if_article_id to swap content as desired.


Code is topiary

Offline

#11 2010-12-19 22:21:11

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: Article from a section in place of an article in another section

Jeff,

I’m using section/category/title as url scheme and I don’t know if it’s possible to achieve this through the use of categories as a glue…
Strange when I’m standing in an article list context, on the top of the other empty section (where I haven’t saved any articles in), for example, I have all my articles. It’s when I’m going deeper to the article url that I get a 404.
Isn’t there an additional way to do this without any further user input ? A plugin for traversing a site’s tree maybe…

Last edited by hablablow (2010-12-19 22:25:55)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#12 2010-12-19 22:31:37

ibob
Member
From: Finland
Registered: 2010-06-14
Posts: 35

Re: Article from a section in place of an article in another section

I had similar issue with news and news archive sections, but I didnt find any proper solution. So I did something quite ugly. I built href urls in news-archive page this way site.com/news-archive/article-url-title/?s=news-archive&id=<txp:article_id /> so I could display em at news-archive section. Original section is news and url for that is much better: site.com/news/article-url-title

Now when I think of this you could do something bit similar if you create only one section for example “pet”. Then create categories cats and dogs assign both to article. Then just use gbp_permanent_links to use categories in urls and you should be able to have url like site.com/pet/dogs/fritz and site.com/pet/cats/fritz

Last edited by ibob (2010-12-19 22:35:46)

Offline

Board footer

Powered by FluxBB