Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-24 18:19:57

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,126
Website GitHub

How do I use the override form with articles?

I’ve set “Allow form override?” in the advanced prefs to yes (admin tab), and I’m using txp:article with allowoverride="1" but I can only get the override form to work for article lists, not for individual articles. Debug mode then says: Notice: Undefined variable: override_form on line 731 (the line says if override_form then use it, else use normal form).

How do I get it to work for individual articles?

If this is not possible, maybe there’s another way of achieving the same thing? This is what I’m trying to do:

Case 1: I have a “news” section where very different kinds of articles will be posted. It might be a text message such as “happy christmas to all our clients and partners”, it might be “current job opportunity” and it might be a project “currently in progress”. In the last case the project includes photos and data and so is displayed using a different form. I’m using categories elsewhere, so I don’t really want to muddle the client with new categories here.

Case 2: I have an “about us” section and use the columnize plug-in to split the information across 2 columns. In one case I would like to use 3 columns. I made an article form with 3 columns and set it as the override form for that article. It works if that article happens to be the first article of the section (i.e. an article list view), but not if I call up that article specifically (an individual article).

Many thanks for your ideas…


TXP Builders – finely-crafted code, design and txp

Offline

#2 2006-06-24 19:27:19

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How do I use the override form with articles?

allowoverride is 1 by default, so you don’t need to set it. :)

Are you using the development version from svn?

Offline

#3 2006-06-24 19:29:05

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,126
Website GitHub

Re: How do I use the override form with articles?

Yes Mary I am, because I like your admin-side modifications. I meant to write that but forgot, sorry. Is that a known problem?

good to know that allowoverride is standard.

Last edited by jakob (2006-06-24 19:30:08)


TXP Builders – finely-crafted code, design and txp

Offline

#4 2006-06-24 20:03:25

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How do I use the override form with articles?

Is that a known problem?

Yep, it is. A bug that was introduced by r1303. I’d hoped it would be fixed right away, but it hasn’t so I guess I’ll go fix it myself.

Offline

#5 2006-06-24 21:15:50

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How do I use the override form with articles?

Try the latest revision.

Offline

#6 2006-06-24 21:52:53

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,126
Website GitHub

Re: How do I use the override form with articles?

Mary, many thanks for the quick response and the fix. It certainly does now respond to individual article as desired, and that is great :-) I have a second problem, though, that may or may not have something to do with it.

I call txp:article twice on the page, the first time is for a breadcrumb and I designated allowoverride=“0” for this:

<h2><txp:article form="body_titel" limit="1" allowoverride="0" /></h2>

Form: body_titel just includes txp:title in this case, but I have used it on other sections to do a section > category > title breadcrumb trail.

Then lower down on the page template:
<code><txp:if_article_list> <txp:article listform=“body_text” limit=“1” /> <txp:else /> <txp:article form=“body_text” limit=“1” /> </txp:if_article_list></code>

and this is the one I want to override for the 3col article.

At present it overrides both instances of txp:article so that the upper form “body titel” is replaced by entire text within the h2 tag.

How should I best construct the page if two txp:article tags are a problem for override? Or is this something taghandler should watch for (allowoverride=“0”)?


TXP Builders – finely-crafted code, design and txp

Offline

#7 2006-06-24 21:57:42

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: How do I use the override form with articles?

jakob wrote:

<code><txp:if_article_list>
<txp:article listform=“body_text” limit=“1” />
<txp:else />
<txp:article form=“body_text” limit=“1” />
</txp:if_article_list></code>

hi
I dont know if this is specifically related to your problem, but i think you can replace all that snippet by a simple
<code><txp:article form=“body_text” listform=“body_text” limit=“1” /></code>
or even
<code><txp:article form=“body_text” limit=“1” /></code>


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#8 2006-06-24 22:05:30

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How do I use the override form with articles?

I think we’re getting into muddy water here. Exactly what form do your articles normally use?

Offline

#9 2006-06-24 22:20:20

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,126
Website GitHub

Re: How do I use the override form with articles?

The page first shows “Section” > “Article Title” as described above:

Page template: <code><h2><txp:article form=“body_titel” limit=“1” allowoverride=“0” /></h2></code>

Form “body_titel” as follows:
<code><txp:section title=“1” link=“1” /> &rsaquo; <txp:title /></code>

Then follows a horizontal sub-nav menu made out of an article_custom list of the articles of that section:
<code><txp:php> echo article_custom(array(“listform”=>“body_bereichsnav”,“section”=>$GLOBALS[‘pretext’][‘s’]));</txp:php></code>

with form “body_bereichsnav” as follows:
<code><a href=”<txp:permlink />” title=”<txp:title />” ><txp:title /></a><txp:if_last_article><txp:else /> | </txp:if_last_article></code>

Then follows the text of that page, either as the first article of the section for the article list or the individual article chosen:

Page template:
<code><txp:if_article_list>
<txp:article listform=“body_text” limit=“1” />
<txp:else />
<txp:article form=“body_text” limit=“1” />
</txp:if_article_list></code>

Form “body_text” looks like this:

<code><txp:jcb_columnize mode=“string” arg=”+++++” classes=“uniform” classname=“spalten2col” ><txp:body /></txp:jcb_columnize></code>

Form “body_text3col”, which I choose via the override form looks like this:

<code><txp:jcb_columnize mode=“string” arg=”+++++” classes=“unique” classname=“spalten3col” ><txp:body /></txp:jcb_columnize></code>

I hope that hepls clarify things? Thanks again.


TXP Builders – finely-crafted code, design and txp

Offline

#10 2006-06-25 00:01:32

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How do I use the override form with articles?

?

<h2><txp:article limit="1" allowoverride="0" form="body_titel" /></h2>

<txp:php>
global $s;

echo article_custom(array(
	'section' => $s,
	'form' => 'body_bereichsnav'
));
</txp:php>

<txp:article limit="1" form="body_text" />

…and choosing “body_text3col” for your override form should work fine, unless there’s some other condition happening which you haven’t mentioned?

Offline

#11 2006-06-26 18:45:34

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,126
Website GitHub

Re: How do I use the override form with articles?

Hmm, that’s what I thought, except it doesn’t ignore the first txp:article with allowoverride=“0” when it’s an individual article. It’s fine for the article list.

Could it be that doArticles (with an s) includes a check for $allowoverride (line 659 publish.php) and doArticle (without an s) just seems to check if there’s an $override_form, but not if it $allowoverride is set to 0 (line 731 publish.php). If I understand things correctly, in the context of an individual article, it will then use an override form if there is one regardless of other settings. That would explain the observed behaviour.

I tried the following and it seems to work, but please check as I have no idea if this has other repercussions:

In line 707/708 publish.php in the function doArticle I added allowoverride to the $atts array (borrowing the line from doArticles):
<code>‘allowoverride’ => (!$q and !$iscustom),</code>

In line 731 publish.php I added a check for $allowoverride analog the pattern from doArticles fitted to the fetchform for doArticle:
<code>$article = fetch_form(($allowoverride and $override_form) ? $override_form : $form);</code>


TXP Builders – finely-crafted code, design and txp

Offline

#12 2006-06-26 18:52:14

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,126
Website GitHub

Re: How do I use the override form with articles?

maniqui, thanks, you are of course correct.
I had other stuff in there, then gradually reduced it until they were more or less equal.
page template looks a lot neater again as a result.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB