Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2011-07-01 00:56:55

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,400

Re: rah_replace - Search and replace

Does someone detect why the following code in a page with rah_replace doesn’t work?

<txp:output_form form="head" />
<body id="<txp:section />"><txp:rah_replace from="http://domain.de" to="">
<div id="wrapper">
<txp:output_form form="slider" /><txp:if_section name="impressum,kontakt"></txp:rah_replace></txp:if_section>
<section>
<h1><txp:if_section name="xy">xy title<txp:else />other title</txp:if_section></h1>
<txp:article limit="1" sort="position asc" form="artikel" />
</section><txp:if_section name="impressum,kontakt"><txp:rah_replace from="http://domain.de" to=""></txp:if_section>
<txp:output_form form="nav" />
<txp:output_form form="footer" /></txp:rah_replace>
</div>
</body>
</html>

It works only for the sections “impressum” and “kontakt”. In the other sections the forms “nav” and “footer” are not parsed. I don’t see where I made a mistake.

Offline

#12 2011-07-01 01:01:55

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: rah_replace - Search and replace

You are closing the rah_replace tag outside the if_section conditional (and opening it inside…)

Edit: ah, wait, I see now what you are doing. You don’t want to apply rah_replace to the <section> part, right?

Last edited by Els (2011-07-01 01:05:23)

Offline

#13 2011-07-01 01:13:40

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: rah_replace - Search and replace

I wouldn’t be surprised if it just isn’t possible to include only either the opening tag or the closing tag in if_section conditionals. Does something like this work (requires a little bit more code)?

<txp:output_form form="head" />
<body id="<txp:section />">
<txp:rah_replace from="http://domain.de" to="">
<div id="wrapper">
<txp:output_form form="slider" />
</txp:rah_replace>
<section>
<txp:if_section name="impressum,kontakt">
<h1><txp:if_section name="xy">xy title<txp:else />other title</txp:if_section></h1>
<txp:article limit="1" sort="position asc" form="artikel" />
<txp:else />
<txp:rah_replace from="http://domain.de" to="">
<h1><txp:if_section name="xy">xy title<txp:else />other title</txp:if_section></h1>
<txp:article limit="1" sort="position asc" form="artikel" />
</txp:rah_replace>
</txp:if_section>
</section>
<txp:rah_replace from="http://domain.de" to="">
<txp:output_form form="nav" />
<txp:output_form form="footer" />
</txp:rah_replace>
</div>
</body>
</html>

Offline

#14 2011-07-01 01:17:57

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: rah_replace - Search and replace

Or maybe just this:

<section>
<txp:if_section name="impressum,kontakt"><txp:else /><txp:rah_replace from="http://domain.de" to=""></txp:if_section>
<h1><txp:if_section name="xy">xy title<txp:else />other title</txp:if_section></h1>
<txp:article limit="1" sort="position asc" form="artikel" />
<txp:if_section name="impressum,kontakt"><txp:else /></txp:rah_replace></txp:if_section>
</section>

Offline

#15 2011-07-01 01:29:33

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,400

Re: rah_replace - Search and replace

Thanks for your answer, Els.

That with <txp:else /> in your answer #14 I had also tried, but that has changed nothing.

I will try your suggestion in #13.

Offline

#16 2011-07-01 02:02:43

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,400

Re: rah_replace - Search and replace

Your idea in #13 works. I’ve adapted it to my needs:

<txp:output_form form="head" />
	<body id="<txp:section />">
		<div id="wrapper">
			<txp:rah_replace from="http://domain.de" to="">
				<txp:output_form form="slider" />
			</txp:rah_replace>
			<section>
			<txp:if_section name="impressum,kontakt">
				<h1>normal title</h1>
				<txp:article limit="1" sort="position asc" form="artikel" />
			<txp:else />
				<txp:rah_replace from="http://domain.de" to="">
					<h1><txp:if_section name="xy">XY title<txp:else />Normal title</txp:if_section></h1>
					<txp:article limit="1" sort="position asc" form="artikel" />
				</txp:rah_replace>
			</txp:if_section>
			</section>
			<txp:rah_replace from="http://domain.de" to="">
				<txp:output_form form="nav" />
				<txp:output_form form="footer" />
			</txp:rah_replace>
		</div>
	</body>
</html>

It could be that in my first version the HTML5 element <section> interferes with <txp:if_section>. I don’t know it.

Offline

#17 2011-07-01 02:37:43

Gocom
Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: rah_replace - Search and replace

GugUser wrote:

It could be that in my first version the HTML5 element <section> interferes with <txp:if_section>.

Markup has no effect to server-side Textpattern tags, the element isn’t interfering. It’s all about the nesting of the tags. A block needs to be closed on the same level as it was opened. An open parent container tag can not be closed inside a child block.

In your first version you had structure outline is similar to:

<foo>
	<bar>
		</foo>
	</bar>

Such block nesting isn’t possible. Closing foo should be outside bar:

<foo>
	<bar>
	</bar>
</foo>

Offline

#18 2011-07-01 03:23:07

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,400

Re: rah_replace - Search and replace

That was the reduced scheme of my first code:

<txp:rah_replace from="http://domain.de" to="">

	HTML group 1

	<txp:if_section name="kontakt">
		</txp:rah_replace>
	</txp:if_section>

	HTML group 2

	<txp:if_section name="kontakt">
		<txp:rah_replace from="http://domain.de" to="">
	</txp:if_section>

	HTML group 3

</txp:rah_replace>

My intention was that the three HTML groups 1-3 are within one rah_relace, except in the section “kontakt” in which the HTML group 2 is excluded. That would be possible with HTML elements, but not with closing and opening Textpattern tags.

Thank you Els and Gocom for your answers and comments.

Offline

#19 2012-02-06 14:02:44

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,598

Re: rah_replace - Search and replace

Hi Jukka – a hopefully easy question if you’re around and reading this thread: I’d like to be able to remove everything between <txp:rah_replace> and </txp:rah_replace>, primarily so I can leave comments in a form/page/etc without it being seen on the front end and reduce load times. Is there a wildcard operator for from in this instance?

Thanks in advance!

Offline

#20 2012-02-06 14:56:26

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,548
Website

Re: rah_replace - Search and replace

HI Pete,

I usually use <txp:hide> ... your memory dump here ... </txp:hide> for this.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB