Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-11-06 00:34:17
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Can I post multiple sections of an article?
Hi forum,
I want to write two–three blocks of text per article and publish them as one article. For instance:
Headline
Section 1
Section 2
Section 3
(Summary/Promo)
I want different sections because of how I want to present it. (I need to put it in three different places in the HTML.)
Can I do this with Textpattern; and how?
Offline
Re: Can I post multiple sections of an article?
You could do something similiar it with a plugin, rss_auto_excerpt and txp:article_custom
Example at section one: <txp:article_custom id="1" form="part1" />
at section two <txp:article_custom id="1" form="part2" />
And in the article form named part1:
<txp:title />
<txp:rss_auto_excerpt skipparagraphs="0" paragraphs="1" />
And in the article form name part2
<txp:title />
<txp:rss_auto_excerpt skipparagraphs="1" paragraphs="9999" />
Cheers!
Last edited by Gocom (2007-11-06 00:55:15)
Offline
Re: Can I post multiple sections of an article?
Wow I never thought of using rss_auto_excerpt for doing this. thanks gocom! I can use this too.
If each section has a variable number of paragraphs, then the skipparagraphs in rss_auto_excerpt will not work… I guess I can simulate the paragraphs with <br /><br /> instead of using <p></p>? Not really ideal…
I can also use the excerpt field and the custom fields as sections if the sections are not that long. Hmm have to revamp my design now.. thanks.
Last edited by JonahC (2007-11-06 02:37:09)
Jonah Calinawan
www.foodportraits.com
Offline
#4 2007-11-06 10:21:48
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Re: Can I post multiple sections of an article?
Yeah…. These ‘hacks’ can work. But not what I had in mind. I would like to see the various sections in the CMS editor tool too. Ideas?
Offline
Re: Can I post multiple sections of an article?
Gocom, that’s a mighty smart idea you had there :-)
Aleksanderen, if you want the back-end to have three+ building blocks which each have a txp_tag of their own, I guess you’re going to have to use a hack like this one (end of first page, not alse line numbers may now be different) which repurposes custom-fields into textareas. Then you can place the different sections completely independently using txp:custom_field.
Another approach more along gocom’s lines but with user-definable breaks between the divs would be to use jcb_columnize with manual breaks, which is normally used to chop txp:body into different div’s for columns, but you could also use for arranging div’s differently on the page. For instance you add (empty line) +++++ (empty line)
where the break should occur in your txp:body. They are then output to separate divs, though one behind the other, so it’s down to your CSS skills to position them how you want. Maybe one of the pagination plug-ins (etz_…) may allow you to do something similar (I’ve just not tried them myself).
If, however, you want different parts of a single article to appear in different txp sections, I think you need to go back to the drawing board and re-consider your site structure.
Last edited by jakob (2007-11-06 14:08:31)
TXP Builders – finely-crafted code, design and txp
Offline
#6 2007-11-06 23:01:35
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Re: Can I post multiple sections of an article?
Most articles will have three sections that are to be styled differently. I know I could just add <div id=“something” />. However I would like to be able to change the structual markup. That is why I do not want to ‘hack’ anything. I would also like to use the second and fourth section as <meta> tags.
Last edited by Aleksandersen (2007-11-06 23:03:35)
Offline
Re: Can I post multiple sections of an article?
Hi Aleksandersen, you sound so disappointed … but without more infos it’s difficult to help any further. Perhaps you can elaborate in more detail as you clearly have very specific ideas when you talk about second and fifth sections (which we can only guess about as you didn’t mention it earlier). Some of the suggestions already made do allow you to change the structural markup:
To recapitulate:
Out of the box, txp comes with a title field (=headline), a body (=section 1), and an excerpt field (=summary/promo) for each article. The title is one line, the body an unlimited textarea, the excerpt a smaller textarea but the amount of text it can contain is not artificially limited.
Then along the side there is a keywords block, which you can use to insert into your meta block and on top of that there are 10 custom fields which you can use for whatever you want.
Each of these have their own txp:tag, e.g. txp:title, txp:body, txp:excerpt txp:custom_field … which you can place almost anywhere you want on your page and use in different combinations on different pages. A typical setup is to use txp:keywords for meta keywords and txp:excerpt, which you have as a promo, for meta description too.
With that you already have your Headline, Section 1, Section 2, and Summary from the standard setup. All you’re missing is a Section 3.
Approach 1: We’ve made different suggestions for splitting Section 2 (body) into subsections, 2a, 2b, 2c… which may work if Sections 2 and 3 always appear together.
Approach 2: If the Section 2a, 2b, 2c… is not feasible because Section3 will be used on its own without Section 2 (i.e. on a totally different page), then the hack I mentioned in the thread will do what you want.
It doesn’t change or destroy any of the rest of the site nor require any special non-standard functions, it just expands the usability of an existing custom_field, allowing it to be longer than 256 character limit and shifting it into the main area as an editable textarea rather than an input field on the side. It’s a primarily cosmetic change that will only ever impact on you again when you come to upgrade – then you will need to transfer the few lines of changed code in article.php to the new article.php from a new version.
An example for approach 2: I made a glossary using txp where I didn’t need the standard title, body, excerpt entry scheme, but three language fields and some notes fields. Here’s a picture of the back-end. Compare it with a normal setup and you can see what I mean. Otherwise the use of txp and the txp:tags are identical, only the entry window has been modified (and some back-end styling).
TXP Builders – finely-crafted code, design and txp
Offline
#8 2007-11-07 09:56:41
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Re: Can I post multiple sections of an article?
This is what I have in mind.
<meta name="description" value="The RSS summary description." />
<meta name="audience" value="Linux users who ... " />
<h1>Ultimate wifi guide</h1>
<p id="audience">Linux users who ... </p>
<p id="dependencies">wireless-tools dhclient</p>
<p>This is the article main body omg.</p>
The audience and dependencies blocks beneeth the headline will have their own style. Dependencies will be modified using JavaScript too. However I want to be forward thiking. In the future I want to be able to say (ignoring meta):
<article><header>
<h1>Ultimate wifi guide</h1>
<section><p id="audience">Linux users who ... </p>
<p id="dependencies">wireless-tools dhclient</section></header></p>
<section><p>This is the article main body omg.</section></p>
Notably not all articles will have all these blocks. So I would need some <?php if(summary()) { do nothing; } ?> thingy too.
Offline
Re: Can I post multiple sections of an article?
not sure I understand how your first and second examples differ – I’m guessing what you call header and section refer to areas of the page (i.e. not head in as it’s called in html and not what a section is called in txp, which is a site section) in a sort of xml-like container-syntax (except that in your example they’re crossing with your p-tags). txp uses both tags that enclose and tags that are standalone with xml-like syntax, e.g.
<txp:if_excerpt />...<txp:else />...</txp:if_excerpt>
, and <txp:excerpt />
, which is the placeholder for the excerpt.
You can divide your page into div’s or whatever you like – the page (x)html code you can define entirely yourself. Repeating elements, both static and dynamic, can be defined as blocks called forms (presentation > forms tab) and can be included into your page template. Forms are also used by txp:article and txp:article to pull in data from each article.
In your example above <txp:excerpt />
would be the summary, and is also used for the RSS. The tag <txp:if_excerpt>
“renders contents if an excerpt exists for the current article. There are other if_empty/if_not_empty tags available via plug-ins.
TXP Builders – finely-crafted code, design and txp
Offline
#10 2007-11-07 22:31:21
- Aleksandersen
- Member
- From: Lillehammer, Norway
- Registered: 2007-04-12
- Posts: 77
Re: Can I post multiple sections of an article?
I wanted to show why I would like to separate the content blocks; using the examples.
Offline