Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-12-05 00:38:11
- davidcorn
- New Member
- Registered: 2007-12-04
- Posts: 4
Place an article inside another article
I have a client that needs custom sidebars. She needs to be able to create the sidebars and choose which sidebar goes on each individual article page. Some articles will have no sidebar at all.
I created two sections – About (uses the About page) and Sidebars (uses the Sidebar page). I have a custom field “display_sidebar” where you can enter the ID of any article. It writes the corresponding article fine. However, it is also writing the title of the sidebar article. Due to some unique requirements of the site this is a bad thing. Any thoughts on what is causing this? I’m using asy_wondertag and hak_tinymce. Here’s what I have so far…
The About page:
<div id="main">
<txp:article form="custom" />
</div><!-- end main -->
<txp:output_form form="sidebar" />
The Sidebar page:
<txp:article form="custom" />
Article form “custom”:
<txp:body />
Article form “sidebar”
<txp:if_custom_field name="display_sidebar">
<div id="sidebar">
<txp:asy_wondertag><txp:article_custom id="<txp:custom_field name="display_sidebar" />" /></txp:asy_wondertag>
</div><!-- end sidebar -->
</txp:if_custom_field>
Offline
Re: Place an article inside another article
Not sure if I understand you correctly – could you clarify the site reqs? If you don’t want to display the title on the about page, then try this in your default form (your sidebar form calls it with the article custom):
<txp:if_section name="about">
<txp:title />
</txp:if_section>
Last edited by jm (2007-12-05 01:14:07)
Offline
Re: Place an article inside another article
I’m not too sure either, but might it be the use of the <txp:article_custom />
tag in the “sidebar” form which is not context-sensitive? I think you need to specify the “section” attribute for that tag otherwise it will call articles from all sections.
Last edited by thebombsite (2007-12-05 01:19:23)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Place an article inside another article
I’m not too sure either, but might it be the use of the <txp:article_custom /> tag in the “sidebar” form which is not context-sensitive? I think you need to specify the “section” attribute for that tag otherwise it will call articles from all sections.
That <txp:article_custom />
has id
-attribute selected ;)
Cheers!
Offline
#5 2007-12-05 01:35:34
- davidcorn
- New Member
- Registered: 2007-12-04
- Posts: 4
Re: Place an article inside another article
Sorry I’ll try to rephrase.
I have an article, About Us, that lives in the About section. About Us needs to pull another article that lives in section Sidebars, and display it on the right side of the page. The only way I know how to do that is with <txp:article_custom id=”…” – and it works, except that it is showing the title of the article in the Sidebar section and for this particular site that is no good.
Rereading the definition of <txp:article_custom, I understand why it is doing that. Is there another way I can approach this?
Offline
#6 2007-12-05 01:56:17
- davidcorn
- New Member
- Registered: 2007-12-04
- Posts: 4
Re: Place an article inside another article
I found a plugin that accomplishes this. Lovely. Thanks all!
Last edited by davidcorn (2007-12-05 01:57:52)
Offline
Re: Place an article inside another article
davidcorn,
You don’t need that plugin. Just use:
<txp:asy_wondertag><txp:article_custom id="<txp:custom_field name="display_sidebar" />" form="body" /></txp:asy_wondertag>
And in article form called body:
<txp:body />
Only case was, that your <txp:article_custom />
called form default, that includes the title, and so on it was outputted. And for pulling those articles from section, you could also use section
-attribute and sort them with sort="rand()"
and limit them with limit="1"
.
See: article_custom and with that we get:
<txp:article_custom form="body" section="sidebars" limit="1" sort="rand()" />
Cheers!
Last edited by Gocom (2007-12-05 02:23:45)
Offline
#8 2007-12-05 04:33:07
- davidcorn
- New Member
- Registered: 2007-12-04
- Posts: 4
Re: Place an article inside another article
Gocom,
That worked perfectly – I didn’t think about it pulling the default form. Thanks much!
Offline