Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2008-12-01 22:11:06

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Php

Could this conflict with PHP in other forms??? If so this isn’t going to work, as I can’t <<< every single bit of PHP i have running throughout my site, Txp is supposed to make life easier not complicate it!


~ Cameron

Offline

#14 2008-12-01 22:20:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,430
Website GitHub

Re: Php

driz wrote:

This site is not fully compatible with Internet Explorer! But, if you want to <a href=“echo $_SERVER[‘PHP_SELF’];?warned=true”>go in anyway</a>, be our guest.

That won’t work. You are already “inside” a PHP echo statement (the one between <<<EOS... EOS;) so you can’t put another echo inside it. You need to set up the link ahead of time and include it within braces. See my example a few posts ago with the $link_name in it. That’s the exact mechanism (almost the exact code) you’ll need to do that bit.

Re your recent post, you don’t need to worry about it conflicting across forms because it only applies on a form by form basis. But having said that I don’t know if it’ll work if you put <txp:... /> tags inside the heredoc. You could try it. My guess is it will work, because I think TXP just does a text replace, but you’re getting into the intricacies of the parser there which is totally out of my depth, so someone else will have to point you in the right direction.

As for it cutting off your DECLARATION, is the companion EOS; — for the second heredoc block — right at the bottom of the code after the closing </html>? Once you’ve got rid of the error in your first heredoc block, the only other way it would be cutting it off early is if you have the exact sequence of characters EOS; in the very leftmost column of the stuff you want to print out. That’s not very likely but if you think your HTML may contain such a sequence of characters, choose something else unique as the heredoc delimiter (e.g. <<<DRIZ_RULEZ_PHP ... )

EDIT: and seriously consider Neko’s suggestion below. It might well save you a headache.

Last edited by Bloke (2008-12-01 22:23:53)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2008-12-01 22:21:47

Neko
Member
Registered: 2004-03-18
Posts: 458

Re: Php

Just to add more noise and confusion: I’m sorry, couldn’t you just use a JS script that sets a cookie on a link (like a close div link) in combination with a conditional CSS served to IE only? :)

Offline

#16 2008-12-01 22:27:39

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Php

Maybe chs_cookie can help achieve what you’re trying to do with out PHP. It looks like there is a thread about doing something similar.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#17 2008-12-01 22:28:07

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Php

Here is the code:

<txp:php>
$warned = isset($_COOKIE['warned']) ? $_COOKIE['warned'] : $_GET['warned'];
if(strpos($_SERVER["HTTP_USER_AGENT"], "WebKit") && $warned != 'true'){
echo <<<BLOCK_ONE
<html>
	<head>
		<title></title>
	</head>
	<body>
		This site is not fully compatible with Internet Explorer!  But, if you want to <a href="">go in anyway</a>, be our guest.
	</body>
</html>
	BLOCK_ONE;
}else{
	if(!isset($_COOKIE['warned'])){
		setcookie('warned', 'true');
	}

echo <<<BLOCK_TWO

<txp:output_form form="html_head" />
<txp:output_form form="header" />

<div id="container">

<div id="teaser">
	<script type="text/javascript">
		// <![CDATA[

		var so = new SWFObject("/media/swf/index.swf", "Index", "980", "450", "9", "101010");
		so.addVariable("flashVarText", "this is passed in via FlashVars for example only");
		so.addParam("menu", "false");
		so.addParam("scale", "noscale");
		so.write("teaser");

		// ]]>
	</script>
	</div>

		<div id="body">

			<div id="index">

    			<div class="box">
    			<div class="box-inside">

      				<h3>Latest <span>Articles</span></h3>
      				<h4>from the weblog</h4>

				<a title="RSS Feed" href="http://simplecandy.com/rss/?section=weblog" id="feed"></a>

					<ul class="newslink">
<txp:article_custom section="weblog" limit="3" form="articlelist" />
					</ul>

				</div><!--//box-inside-->
    			</div><!--//box-->

    			<div class="box">
    			<div class="box-inside">


			</div><!--//box-inside-->
    			</div><!--//box-->

    			<div class="box lastchild">
    			<div class="box-inside">

      				<h3>About <span>( SC )</span></h3>
      				<h4>Learn About The Company</h4>
					<p style="text-align:justify;margin:0;">Hello there! We build <a href="http://www.panic.com/coda/">hand-coded</a>, <a href="http://www.webstandards.org/">standards-based</a> websites. We really love working with Textpattern. Feel free to take a look around. Have a nice day. x</p>

				</div><!--//box-inside-->
				</div><!--//box-->

			</div><!--//index-->

		</div><!--//body-->

<txp:output_form form="footer" />

BLOCK_TWO;
}
</txp:php>

It is still not working though! I really don’t like the fact I’m having to do this, why can’t I use blocks of PHP? Why can’t Textpattern work with it? It’s PHP based :S

It actually just breaks my site: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/driz/public_html/admin/publish/taghandlers.php(2804) : eval()’d code on line 15

Last edited by driz (2008-12-01 22:31:34)


~ Cameron

Offline

#18 2008-12-01 22:36:00

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,430
Website GitHub

Re: Php

The closing BLOCK_ONE; should be left-aligned or it’ll never get out of the first echo statement.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#19 2008-12-01 22:37:46

Neko
Member
Registered: 2004-03-18
Posts: 458

Re: Php

driz wrote:

It is still not working though! I really don’t like the fact I’m having to do this, why can’t I use blocks of PHP? Why can’t Textpattern work with it? It’s PHP based :S

Well, you can use raw PHP without the proper TXP tags. Just enable it in Advanced Preferences

It actually just breaks my site: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/driz/public_html/admin/publish/taghandlers.php(2804) : eval()’d code on line 15

Maybe you forgot to type a few ; after your echos?

Last edited by Neko (2008-12-01 22:37:57)

Offline

#20 2008-12-01 22:49:56

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Php

Okies finally cracked it and it works perfect, although it gets ugly backend!

I didn’t want to use JS because its front-end, I want most of my stuff to happen back-end so people can’t see it!
I like the sound of this plugin though, but I can’t make much sense of it, how exactly would I be able to achieve what I have done here using that plugin? Thanks. x


~ Cameron

Offline

#21 2008-12-01 22:52:41

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Php

You can do this using chs_cookie and smd_if

<txp:chs_set_cookie cookie="simplecandy_warned" value="warned" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<body>
<txp:smd_if field="svrvar:HTTP_USER_AGENT"
     operator="contains"
     value="WebKit">
This is a good browser
<txp:else/>

<txp:chs_cookie_default cookie="simplecandy_warned" value="warned">
Warning Message
<li><form action="<txp:permlink />" method="get" accept-charset="utf-8">
	<input type="submit" value="Continue &rarr;" />
</form>	</li></ul>
</txp:chs_cookie_default>
<txp:chs_if_cookie cookie="simplecandy_warned" value="warned">
Ok to see content.
</txp:chs_if_cookie> 
</txp:smd_if>
</body>
</html>

Thrown together but could be tweaked to perfection

Last edited by MattD (2008-12-01 22:53:46)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#22 2008-12-01 22:58:52

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Php

Seems to me it says if you have WebKit say they have browser, else show the form, and then see the content?
Would the user see the Good browser statement AND the content, or just the statement? Looks like three different blocks of content to me!!!

Basically why is the content before the else statement! We have ‘Good Browser’, The Form, and ‘Okay Content’
Thats three separate bits, wouldn’t it be just if no cookie show form, if cookie, show content? just two bits :S

Last edited by driz (2008-12-01 23:07:37)


~ Cameron

Offline

#23 2008-12-01 23:05:34

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Php

I think the content would have to be in the template twice.

<txp:chs_set_cookie cookie="simplecandy_warned" value="warned" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<body>
<txp:smd_if field="svrvar:HTTP_USER_AGENT"
     operator="contains"
     value="MSIE">

<!-- IE is being used. Display the warning -->

<txp:chs_cookie_default cookie="simplecandy_warned" value="warned">
Warning Message
<li><form action="<txp:permlink />" method="get" accept-charset="utf-8">
	<input type="submit" value="Continue &rarr;" />
</form>	</li></ul>
</txp:chs_cookie_default>
<txp:chs_if_cookie cookie="simplecandy_warned" value="warned">

<!-- IE is being used and warning has already been displayed -->

Ok to see content.
</txp:chs_if_cookie>
<txp:else/>

<!-- IE is not being used -->

Also Ok to see content. 
</txp:smd_if>
</body>
</html>

EDIT: The best way around that would be to have your content in a seperate form so both content blocks could just have a <txp:form form="myContent"/> line

Last edited by MattD (2008-12-01 23:07:25)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#24 2008-12-01 23:11:22

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Php

Ah, I think i missed the point, so you see the content if your with WebKit, if not see the warning, and then go to the content, the only issue is the duplicate content, I DONT want to put my content inside a form, because thats the whole site, and well thats messy!

Isn’t their someway to just say one or the other, so basically if no cookie show form, if cookie, show content? just two bits :S


~ Cameron

Offline

Board footer

Powered by FluxBB