Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Central storage for site-wide constants: Helpful?
Of course… my (and yours) examples don’t make ANY sense at all…
I’m ashamed of it… it looks “clever” at first, but now, my code looks stupid…
Let’s keep thinking…
Offline
#74 2008-07-07 20:50:31
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Central storage for site-wide constants: Helpful?
I’m not experienced with applying comments, it’s just that I see that the comments tag is something like the article tag, i.e. it can call forms. The class needs to be given in that form (i.e. individually), but not to all articles/comments, I think. Does that make sense?
Edited for textiling
Last edited by uli (2008-07-07 20:51:25)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Central storage for site-wide constants: Helpful?
maverick wrote:
Or maybe a <txp:if_variable name=“comment_author” /> = <txp:variable name=“article_author” />
:-) Closer than you think… umm, I think. Off the top of my head, in your comment form as uli sugggests:
<txp:variable name="this_comment" value='<txp:comment_name />' />
<txp:if_variable name="this_comment" value='<txp:author />'>
// Apply the author style
</txp:if_variable>
Untested, and probably utter carp, but perhaps worth experimenting with.
EDIT: and of course it depends if <txp:author /
returns the “real name” or the “user name”. Can’t remember.
Last edited by Bloke (2008-07-07 21:21:44)
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
Online
#76 2008-07-07 21:29:02
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Central storage for site-wide constants: Helpful?
To a certain degree OT, but we’re talking about comments at the moment: I needed to use Textbook for my last post and saw that <txp:comments />
isn’t mentioned on the page with page/column related tags. Where is the right place to ask for adding it there?
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
#77 2008-07-07 21:49:58
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Central storage for site-wide constants: Helpful?
uli wrote:
<txp:comments />
isn’t mentioned on the page with page/column related tags.
Well, it shouldn’t be there, the tag belongs in an article form :)
Offline
#78 2008-07-07 21:55:19
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Central storage for site-wide constants: Helpful?
Sometimes it’s rather good when the counter is closed or hidden ;))
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Central storage for site-wide constants: Helpful?
Bloke wrote:
Untested, and probably utter carp, but perhaps worth experimenting with.
Will try it out when I get a chance. Have to take off for a bit.
EDIT: and of course it depends if
<txp:author /
returns the “real name” or the “user name”. Can’t remember.
It returns the “real name”.
At this point its more an exercise in understanding txp:variable and nested tags, and proof of concept. I suspect that in the end it might be more simple to use a one of the excellent plugins out there ;)
Offline
Re: Central storage for site-wide constants: Helpful?
Bloke wrote:
<txp:variable name="this_comment" value='<txp:comment_name />' />
<txp:if_variable name="this_comment" value='<txp:author />'>
// Apply the author style
</txp:if_variable>
EDIT: and of course it depends if
<txp:author /
returns the “real name” or the “user name”. Can’t remember.
Probably less prone to errors could be to compare the commenter email against the author e-mail, which can’t be currently retrieved by txp tags, so it could be compared to a custom field that has author’s e-mail.
<txp:variable name="this_comment" value='<txp:comment_email />' />
<txp:if_variable name="this_comment" value='<txp:custom_field name="author_email" />'>
// Apply the author style
</txp:if_variable>
Offline
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
Online
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: 4,306
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
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:
- I tried an example tag earlier and surrounded the attribute with double quotes and it still parsed it. *confused*
- 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
Online