Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-09-19 16:50:29

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

add a default value to comment_name_input & comment_email_input

Hello Txp Community,

With <txp:cbe_frontauth_if_logged>, I want add default author connected name to comment_name_input tag and this email to comment_email_input tag.

Is there a solution ?

These tags have no attributes and lack of flexibility unlike other txp tags. Why no wrap, class or value attribute ?

Thanks

Offline

#2 2012-09-19 16:57:12

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: add a default value to comment_name_input & comment_email_input

Hi sacripant.
I think etc_query can help you. Look at the Help docs, there is an example about how to process some “hardcoded” output from TXP tags. Alternatively, you may be able to solve this via JS.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#3 2012-09-19 17:59:20

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: add a default value to comment_name_input & comment_email_input

Hi guys.

You can try to replace <txp:comment_name_input /> in comment_form with

<txp:variable name="user_name" value='<txp:cbe_frontauth_whois type="RealName" />' />

<txp:etc_query data='<txp:comment_name_input />'
	query="input[@id='name']"
	sanitize="variable"
	replace="@@value={?user_name}" />

I have wrapped <txp:cbe_frontauth_whois type="RealName" /> in a variable only to escape it.

If you prefer JS, you must pass user name on the client side, so you’ll have to inject it somewhere anyway, but it’s feasible.

Offline

#4 2012-09-20 11:19:37

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: add a default value to comment_name_input & comment_email_input

Thanks etc, thanks maniqui.

Never use etc_query. It’s a big plugin.
Use etc_query for that, it’s like out a tank to kill an ant ? non ?

I use Javascript, waiting maybe a better flexibility for comment tags.

Offline

#5 2012-09-20 11:33:30

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: add a default value to comment_name_input & comment_email_input

sacripant wrote:

Use etc_query for that, it’s like out a tank to kill an ant ? non ?

Si! and thus all the funnier. Honestly, etc_query is called a dozen of times on this page, without any noticeable drawback.

Last edited by etc (2012-09-20 15:46:40)

Offline

Board footer

Powered by FluxBB