Textpattern CMS support forum

You are not logged in. Register | Login | Help

#81 2008-07-07 22:16:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 7,752
Website

Re: Central storage for site-wide constants: Helpful?

maniqui wrote:

Probably less prone to errors could be to compare the commenter email against the author e-mail

Makes sense, especially if ‘remember’ is off. I’d guess for the most part the name would be ok since were comparing the author themselves and they’re more likely to have ‘remember’ on.

But if you want to get the author e-mail you can drop into PHP somewhere in your article form and do something like:

<txp:variable name="author_email" value='<txp:php>global $thisarticle; echo safe_field("email","txp_users","name='".$thisarticle['authorid']."'");</txp:php>' />

Then in your comment form:

<txp:variable name="this_comment" value='<txp:comment_email />' />
<txp:if_variable name="this_comment" value='<txp:variable name="author_email" />'>
 // Apply the author style
</txp:if_variable>

Or use jmd_author instead of the hunk of PHP, but as maverick says, with all this extra stuff it may well be easier to use the excellent sed_comment_pack and be done with it!


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

#82 2008-07-07 22:18:56

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 957
Website

Re: Central storage for site-wide constants: Helpful?

Okay, I’m obsessive and didn’t take off yet. :) Uli and Bloke – your suggestions worked.

Here’s what I did based on your posts:

form – comments
<txp:output_form form=“comment_class” />
<div class=’<txp:variable name=“comment_class” />’> comment tags
</div>

form – comment_class
<txp:variable name=“comment_author” value=’<txp:comment_name />’ />
<txp:if_variable name=“comment_author” value=’<txp:author />’> <txp:variable name=“comment_class” value=“author” /> <txp:else /> <txp:variable name=“comment_class” value=“odd” />
</txp:if_variable>

I hooked into the css I’m using with sed_comment_pack, allowing me to output “author” and “odd” classes/styling so far.

Thanks for pointing us in the right direction!

Mike

Last edited by maverick (2008-07-07 22:28:26)

Offline

#83 2008-07-07 22:44:47

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 3,937

Re: Central storage for site-wide constants: Helpful?

Bloke wrote:

<txp:variable name="author_email" value='<txp:php>global $thisarticle; echo safe_field("email","txp_users","name='".$thisarticle['authorid']."'");</txp:php>' />

Holy moly! Right! Even PHP in tags is feasible now!


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#84 2008-07-07 23:17:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 7,752
Website

Re: Central storage for site-wide constants: Helpful?

maverick

Niiiice.

uli

Yup :-)

Not sure if that example up there is quite right; I still haven’t figured out this single-quote / double-quote lark. From ruud’s blog post I thought that I always surrounded anything that required parsing with single quotes and anything literal (unparsed) in doubles.

But there’s two things I’ve noticed:

  1. I tried an example tag earlier and surrounded the attribute with double quotes and it still parsed it. *confused*
  2. Even if I use combinations of single and double quotes within the attribute I haven’t yet managed to make the parser explode, which is a testament to its awesomeness

Must re-read the blog entry and gain a better understanding, but it really is totally cool to be able to do this kind of thing.


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

#85 2008-07-08 00:03:05

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 3,937

Re: Central storage for site-wide constants: Helpful?

Mike, thanks for sharing, BTW!

Stef, Shouldn’t nested odd/even type of quotes suffice? (Can’t escape zebras these days ;)

Just read jakob’s post in your smd_query thread and must admit that, of all examples I’ve found so far, at the moment he deserves the crown: for nesting a raw php command (into txp:php tags) into an SQL query into a value of a TXP tag! Respect!!

Sorry for not showing any response on your long code example you’ve posted in my direction some miles above. At times I get rather frustrated on not understanding so many things, and smd_each is THE secret to me, at the moment it’s the “variable of all variables”. Will have to visit you over there in the other wing ;)

Last edited by uli (2008-07-08 00:07:31)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#86 2008-07-08 00:22:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 7,752
Website

Re: Central storage for site-wide constants: Helpful?

uli wrote:

Shouldn’t nested odd/even type of quotes suffice? (Can’t escape zebras these days ;)

Probably. I’ll read up on it and play.

Just read jakob’s post in your smd_query thread … he deserves the crown

Yes he does. Very impressive bit of coding. Shame smd_query let him down at the end, though.

Sorry for not showing any response on your long code example you’ve posted in my direction some miles above.

No problem. I just threw it in to show what’s possible with the new tags and some smd_ mentalness.

smd_each is THE secret to me, at the moment it’s the “variable of all variables”.

Hehehe, it is rather entertaining when you start to think through the possibilities of being able to iterate over anything that’s delimited; user input, custom field, keyword… There aren’t many restrictions, and being able to walk over items without having to know how many there are gives some great scope for building, I dunno, forms that can capture and process user input from HTML widgets configured in glz_custom_fields.

Will have to visit you over there in the other wing ;)

I’ll get the coffee on :-)


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

#87 2008-12-02 04:39:55

damienbuckley
Member
From: Brisbane, QLD, AU
Registered: 2006-02-24
Posts: 138
Website

Re: Central storage for site-wide constants: Helpful?

If only ‘Textpattern Solutions 2’ was on the boil… sigh

Offline

#88 2010-01-19 23:56:28

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 2,806
Website

Re: Central storage for site-wide constants: Helpful?

Hi, is Stef’s PHP trick for getting an author’s email address still viable, I can’t seem to get it to work…

<txp:variable name="author_email" value='<txp:php>global $thisarticle; echo safe_field("email","txp_users","name='".$thisarticle['authorid']."'");</txp:php>' />

I also tried jmd_author instead but as that returns email addresses encoded it will not do for my needs.

Thanks,
Phil

Offline

#89 2010-01-20 02:43:23

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,781
Website

Re: Central storage for site-wide constants: Helpful?

The basic code in the raw PHP snippet is fine. But my head spins at trying to sort out which, if any, quote marks would need to be escaped when using that php tag within another tag. Do you need to have this in a variable? If so, you could assign it inside the php tag. Something like:

<txp:php>
   global $thisarticle, $variable; 
   $variable['author_email'] = safe_field("email","txp_users","name='".$thisarticle['authorid']."'");
</txp:php>

Or you could html_entity_decode() the output from jmd_author.


Code is topiary

Offline

#90 2010-01-20 08:54:46

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 2,806
Website

Re: Central storage for site-wide constants: Helpful?

Nice one Jeff, I’ve used your version of the PHP and it now works as intended. Many thanks for the help.

Last edited by philwareham (2010-01-20 09:28:07)

Offline

Board footer

Powered by FluxBB