Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-03 03:06:44

andy.graybeal
New Member
Registered: 2007-03-02
Posts: 5

<txp:php>some php stuff .. </txp:php> txp stuff <txp:php>...con'td php

okay.. i realize that what i’m doing is somehow not right. I got some PHP then some regular TXP stuff.. then i want to pick up where i left off with the PHP stuff again.. just like with regular html.. but i realize that it doesn’t work like that in TXP.. how would i do this otherwise?
-andy

here’s the code:

<!— center —> <div id=“content”> <txp:php> $pattern = ‘/192.168.2.204\/$/’; if (preg_match($pattern, $_SERVER[“HTTP_HOST”].$_SERVER[“REQUEST_URI”])) { </txp:php>

<txp:article_custom section=“dinner-special” limit=“1” /> <txp:article_custom section=“drink-special” limit=“1” /> <txp:article_custom section=“art-show” limit=“1” /> <txp:article_custom section=“tonights-event” limit=“1” />

<txp:php> } else { </txp:php>

<txp:article limit=“5” />

<txp:if_individual_article> <p><txp:link_to_prev><txp:prev_title /></txp:link_to_prev> <txp:link_to_next><txp:next_title /></txp:link_to_next></p> <txp:else /> <p><txp:older><txp:text item=“older” /></txp:older> <txp:newer><txp:text item=“newer” /></txp:newer></p> </txp:if_individual_article> <txp:php> } </txp:php>

</div>

Offline

#2 2007-03-03 12:33:12

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: <txp:php>some php stuff .. </txp:php> txp stuff <txp:php>...con'td php

see FAQ

Offline

#3 2007-03-04 02:23:08

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

Re: <txp:php>some php stuff .. </txp:php> txp stuff <txp:php>...con'td php

It’d be cleaner and simpler to make yourself a simple plugin.

TextBook: Designer and Developer Interests: Plugin Development

function ext_check_ip($atts = array(), $thing = null)
{
	$pattern = '/192.168.2.204\/$/';

	$condition = preg_match($pattern, $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);

	return parse(EvalElse($thing, $condition));
}
<txp:ext_check_ip>

	<txp:article_custom section="dinner-special" limit="1" />
	<txp:article_custom section="drink-special" limit="1" />
	<txp:article_custom section="art-show" limit="1" />
	<txp:article_custom section="tonights-event" limit="1" />

<txp:else />

	<txp:article limit="5" />

	<txp:if_individual_article>
		<p><txp:link_to_prev><txp:prev_title /></txp:link_to_prev> 
			<txp:link_to_next><txp:next_title /></txp:link_to_next></p>
	<txp:else />
		<p><txp:older><txp:text item="older" /></txp:older> 
			<txp:newer><txp:text item="newer" /></txp:newer></p>
	</txp:if_individual_article>

</txp:ext_check_ip>

Offline

#4 2007-03-05 12:14:33

andy.graybeal
New Member
Registered: 2007-03-02
Posts: 5

Re: <txp:php>some php stuff .. </txp:php> txp stuff <txp:php>...con'td php

hmm… interesting! thank you.

Offline

#5 2007-03-14 17:38:41

andy.graybeal
New Member
Registered: 2007-03-02
Posts: 5

Re: <txp:php>some php stuff .. </txp:php> txp stuff <txp:php>...con'td php

Mary, thank you! it worked. It took me a little while to read and learn how to make a plugin; but I got it with Zem’s tutorial and plugin template and compiler! awesome.

Offline

Board footer

Powered by FluxBB