Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2008-12-01 23:20:49

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

Re: Php

driz wrote:

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

That’s not what you want though right? You only want the cookie stuff if their using IE right? Maybe Stef will peek in and tell us if theres a better way but I’m not sure you can make it just one if statement with both conditions. I believe his plugin can do that but I don’t believe it deals with cookie variables.

What you need is a way to get to the cookie variable in smd_if then you could do…

<txp:smd_if field="svrvar:HTTP_USER_AGENT, cookievar:simplecandy_warned"
     operator="contains, eq"
     value="MSIE, warned">

But I don’t think that’s possible. If you could get the cookie value into a txp:variable then smd_if should have access to it but I’ve not used txp:variable enough to help there.

I think we need Stef’s input.


My Plugins

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

Offline

#26 2008-12-01 23:25:56

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

Re: Php

That’s correct I only want the cookie if they are using IE, but in my PHP I get only two parts, a warning and the content! Depending on which browser they are using they get one or the other, that’s the functionality I’m trying to replicate!

Also for the warning, I’m planning on using a txp form, because I want to use different code, to that of my default site, hence why in my PHP it had the html tags twice!!! I don’t know if this makes our problem easier or harder? :)


~ Cameron

Offline

#27 2008-12-01 23:40:55

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

Re: Php

MattD wrote:

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

Well, as Mattd says, you can use smd_if to do both tests at once if you’ve already set the cookie up beforehand. I haven’t employed cookies directly in smd_if (why?! *note to self: add this*) but you can do it in 4.0.7 with the shiny new parser:

<txp:smd_if field='svrvar:HTTP_USER_AGENT, <txp:chs_echo_cookie cookie="simplecandy_warned" />'
     operator="contains, not"
     value="MSIE, warned">
  // This is IE and we have not accepted the warning, so show it
<txp:else />
  // erm.... see below
</txp:smd_if>

but you still have the problem of what to do next. I think your layout implies tertiary logic — as MattD said — so you probably need another smd_if in the <txp:else /> to distinguish the two cases:

  • if IE AND cookie set
  • if any other browser

EDIT: hmmm, or maybe that does work as it is… because if the browser is NOT IE, it ignores the cookie regardless so you might get away with it if you can find a way of setting the cookie somewhere higher up the page. That might require a separate smd_if to check the browser and the status of the urlvar warned and set the cookie if they both match.

Last edited by Bloke (2008-12-01 23:46:08)


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

#28 2008-12-01 23:48:12

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

Re: Php

So what’s the conclusion then? Does your idea work? You post felt more like a discussion with yourself about a theory rather than an actual solution :P

Thanks


~ Cameron

Offline

#29 2008-12-01 23:50:25

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

Re: Php

I hadn’t noticed chs_echo_cookie as the help text was garbled but I was just about to post a solution where for some reason I set a txp:variable using chs_echo_cookie and then checked that in smd_if. Of course that’s not needed.

This should work

<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, <txp:chs_echo_cookie cookie="simplecandy_warned" />'
     operator="contains, not"
     value="MSIE, warned">
Warning Message
<li><form action="<txp:permlink />" method="get" accept-charset="utf-8">
	<input type="submit" value="Continue &rarr;" />
</form>	</li></ul>
<txp:else/>
Ok to see content. 
</txp:smd_if>
</body>
</html>

My Plugins

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

Offline

#30 2008-12-01 23:56:40

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

Re: Php

MattD wrote:

I hadn’t noticed chs_echo_cookie as the help text was garbled but I was just about to post a solution where for some reason I set a txp:variable using chs_echo_cookie and then checked that in smd_if. Of course that’s not needed.

This should work

<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, <txp:chs_echo_cookie cookie="simplecandy_warned" />'
     operator="contains, not"
     value="MSIE, warned">
Warning Message
<li><form action="<txp:permlink />" method="get" accept-charset="utf-8">
	<input type="submit" value="Continue &rarr;" />
</form>	</li></ul>
<txp:else/>
Ok to see content. 
</txp:smd_if>
</body>
</html>

doesn’t work, outputs all the content and form
im testing it here: http://simplecandy.com/about/

see


~ Cameron

Offline

#31 2008-12-01 23:58:41

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

Re: Php

Works for me on my site

Edited: Looks like somethings wrong since I see the smd_if tag in your source.

Last edited by MattD (2008-12-02 20:10:44)


My Plugins

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

Offline

#32 2008-12-02 00:02:02

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

Re: Php

know what the issue is? x


~ Cameron

Offline

#33 2008-12-02 00:04:02

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

Re: Php

Looks like you missed part of the first smd_if tag. Click Quote on my post to make sure you see the entire thing. For some reason the forum seems to run off the right side of the page sometimes.

EDIT: or get it from here

Last edited by MattD (2008-12-02 00:05:44)


My Plugins

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

Offline

#34 2008-12-02 00:10:55

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

Re: Php

are you sure? i have the exact same code:

<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, <txp:chs_echo_cookie cookie="simplecandy_warned" />'
     operator="contains, not"
     value="WebKit, warned">
Warning Message
<li><form action="<txp:permlink />" method="get" accept-charset="utf-8">
	<input type="submit" value="Continue &rarr;" />
</form>	</li></ul>
<txp:else/>
Ok to see content. 
</txp:smd_if>
</body>
</html>

~ Cameron

Offline

#35 2008-12-02 00:13:32

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

Re: Php

Turn debugging on and lets look at the tag trace.

EDIT: Will only work with the new tag parser in 4.0.7

Last edited by MattD (2008-12-02 00:15:17)


My Plugins

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

Offline

#36 2008-12-02 00:32:51

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

Re: Php

Okies problems, first being that can this code work across Forms? I have my code between the body tags like shown, but the body starts in one form and ends in other, likewise for the if statement, this then cuts off my </body></html> tags!

Secondly, the tag doesnt seem to be complaining about IE even when im using IE???

here is my header form:

<txp:chs_set_cookie cookie="simplecandy_warned" value="warned" />

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml2.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

	<head profile="http://gmpg.org/xfn/11">

		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="generator" content="Textpattern" />
		<meta name="description" content="hand-coded webprojects" />
		<meta name="keywords" content="Design, Development, XHTML, CSS, Web 2.0, Web Standards" />

		<title><txp:output_form form="title" /></title>

		<link rel="shortcut icon" type="image/png" href="/favicon.png" />
		<link rel="apple-touch-icon" href="/webclip.png" />

		<txp:feed_link flavor="rss" format="link" label="RSS" />
		<txp:feed_link flavor="atom" format="link" label="Atom" />

		<txp:rvm_css format="link" n="simplecandy" />

		<script type="text/javascript" src="http://simplecandy.com/mint/?js"></script>

		<txp:js n="jQuery" />
		<txp:js n="jQueryDimensions" />
		<txp:js n="jQueryMouseWheel" />
		<txp:js n="jQueryScrollPane" />
		<txp:js n="finder" />
		<txp:js n="swfobject" />
		<txp:js n="FancyZoom" />
		<txp:js n="FancyZoomHTML" />
		<txp:js n="CustomFormElements" />
		<txp:js n="jQueryEasing" />
		<txp:js n="jQueryEasingCompatibility" />
		<txp:js n="jQueryGradient" />
		<txp:js n="CodaSlider" />
		<txp:js n="jQueryLocalScroll" />
		<txp:js n="jQueryScrollTo" />
		<txp:js n="jQueryAccordion" />
		<txp:js n="MatchingHeight" />
		<txp:js n="SCFunctions" />

	</head>

	<body id="<txp:if_section name="default">home<txp:else /><txp:section /></txp:if_section>">

<txp:smd_if field='svrvar:HTTP_USER_AGENT, <txp:chs_echo_cookie cookie="simplecandy_warned" />' operator="contains, not" value="WebKit, warned">

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

<txp:else/>

MY PAGE GOES HERE>>>

and the footer form:

</div><!--//container-->

	<div id="footer">
	<div id="footer-outside">
	<div id="footer-inside" style="width:980px;margin:auto;">

			<p>&copy; <txp:php>echo date(Y);</txp:php> SIMPLECANDY</p>

			<ul style="float:left;">
				<li class="seperator"><a href="/contact/">Contact Info</a></li>
				<!--<li class="seperator"><a href="/">FAQ's</a></li>-->
			</ul>

			<ul>
				<li class="sep"><a href="http://textpattern.com/" title="A flexible, elegant and easy-to-use content management system">Published with Textpattern v4.0.6</a></li>
				<li class="sep"><a href="http://www.apple.com/" title="?">Made on a Macintosh</a></li>
				<li><a href="/backstage/" title="?">BACKSTAGE</a></li>
			</ul>

	</div>
	</div><!--//footer-->
	</div><!--//footer-->

</txp:smd_if>
</body></html>

Last edited by driz (2008-12-02 00:53:03)


~ Cameron

Offline

Board footer

Powered by FluxBB