Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#171 2019-10-16 20:44:31

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,360
Website

Re: com_connect - form and contact mailer

Hi Jakob ;)

Thank you for your reply.

Unfortunately I can’t get a result.
First of all, the varibale declaration need to be as this:

<txp:variable name="ac" value='<txp:page_url type="ac" />' />

Secondly, it seems that the selected attribut for the com_connect plugin do not return any result:

<txp:php>
echo com_connect_option(array(‘label’=>title(array()),‘selected’=>‘My label’));
</txp:php>

Display a blank selected attribute into the form code souce.


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#172 2019-10-16 21:02:34

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,854
Website

Re: com_connect - form and contact mailer

Pat64 wrote #319733:

First of all, the varibale declaration need to be: <txp:variable name="ac" value='<txp:page_url type="ac" />' />

Hmm, I thought both methods – container tag or tag-in-tag attribute – should work.

Secondly, it seems that the selected attribut for the com_connect plugin do not return any result … displays a blank selected attribute into the form code souce.

Not sure if I understood you correctly, but maybe you need to explicitly declare the else case, e.g.

… selected='<txp:if_variable name="ac" value="6">1<txp:else />0</txp:if_variable>' …

What I usually do in such cases, is work through step for step to try and locate the error, e.g.

  • output the variable first to see if it is actually comes through.
  • Try the if…else outside the tag-in-tag to see if it the criteria matching works properly.
  • Try the com_connect_option tag with "1" and "0" values to check if the criteria match property actually produces the desired end result.
  • Also worth a try: putting the if…else into a variable of its own, then using that as the tag-in-tag so that you’re not trying to do logic inside the tag attribute…

TXP Builders – finely-crafted code, design and txp

Offline

#173 2019-10-16 21:30:33

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,360
Website

Re: com_connect - form and contact mailer

Good catch Jakob, you’re right!

The variable statement need a else condition. ;)

For the variable declaration, in my case the tag-in-tag solution did not retrieve any result.

As you said I argue it is verbose but I did not find any more elegant solution…

Thank you lot. I continue to try ;)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#174 2019-10-16 23:06:19

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,360
Website

Re: com_connect - form and contact mailer

Ok. It works fine :D

But I need an only one advice because I can’t find how to achieve (and finish) this form.

Because the form is pretty complex, I use the PHP method to declare the options (lot of ones):

global $variable;

echo com_connect_option(array('label'=>'My Label','selected'=>($variable[''ac] == $rs[''ID] ? '1' : '0')));

But unfortunately I have not the selected attribute into my HTML source code (Notice: the variable is populated).

Could you, please, tell me how to set the selected attribute by the variable into the sample code above? Thank you lot by advance for your help.


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#175 2019-10-17 06:26:22

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,360
Website

Re: com_connect - form and contact mailer

Ok. I changed my code to use some <txp:article_custom /> magic logic instead. :D

I reformulate my demand: how to set the posted attribute to exclude all past publishing until the current date? (I can do that in a Mysql query but not in TXP tags, my bad…)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#176 2019-10-17 06:58:06

etc
Developer
Registered: 2010-11-11
Posts: 3,708
Website

Re: com_connect - form and contact mailer

Pat64 wrote #319735:

The variable statement need a else condition. ;)

<txp:if_variable name="ac" value="6">1<txp:else />0</txp:if_variable>

As you said I argue it is verbose but I did not find any more elegant solution…

Ahem… try

<txp:if_variable name="ac" value="6" escape="integer" />

how to set the posted attribute to exclude all past publishing until the current date?

Isn’t that what time="future" does?

Offline

#177 2019-10-17 07:23:30

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,360
Website

Re: com_connect - form and contact mailer

Thank lot, Oleg!

Strangely, I got better results with time="past" (dealing with date ranges is very enigmatic many times 😱)…

<txp:if_variable name="ac" value="6" escape="integer />

As always, elegant and efficient! 👌🏻

Please, Oleg, accept this golden medal for “The Best Friend of the Day” 🥇

For anyone who want to make some selective options into a com_connect construction, here is the process:

<txp:com_connect_select label="Select a Course (required) *" selected="" break="" class="theme-white" required="1">
	<txp:com_connect_option />

<txp:article_custom section="workshops-retreats" time="past" sort="Posted asc" limit="99">

	<txp:com_connect_option label='<txp:title />' value='<txp:title />' selected='<txp:if_variable name="ac" value=''<txp:article_id />'' escape="integer" />' />

	</txp:article_custom>
</txp:com_connect_select>

Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#178 2019-10-17 07:45:58

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,854
Website

Re: com_connect - form and contact mailer

etc wrote #319739:

Ahem… try: <txp:if_variable name="ac" value="6" escape="integer" />...

Yet another example of much more succinct syntax. So that will work for all attributes that have 1 or 0 (true/false) as an attribute? The same principle as attribute-less attributes is the equivalent of 1?

@Pat, you’re missing some closing quotes after integer in your code above. In your php code, too, you have [''ac] rather than ['ac']. Maybe they were just transfer typos… but if not, that may explain why you weren’t getting what you expected.


TXP Builders – finely-crafted code, design and txp

Offline

#179 2019-10-17 08:00:51

etc
Developer
Registered: 2010-11-11
Posts: 3,708
Website

Re: com_connect - form and contact mailer

jakob wrote #319744:

So that will work for all attributes that have 1 or 0 (true/false) as an attribute?

All <txp:if_something /> tags without content output 1 (true) or nothing (false). Generally, attribute="" works for most tags, but if you explicitly need 0, you can apply escape="integer" to the empty output.

The same principle as attribute-less is the equivalent of 1?

They are not strictly equivalent, a valueless attribute is evaluated as boolean true, not as 1.

Offline

#180 2019-10-17 08:09:16

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,360
Website

Re: com_connect - form and contact mailer

etc and Jakob

I noticed variable deals with strings only.

Am I right, Oleg?

Correction: time="future" is the right solution, I just noticed a big difference between my local server (MAMP) and the production linux server! The raison why I always prefer to work on my projects directly within live servers.

Thanks to you two: you save my day!

Last edited by Pat64 (2019-10-17 08:11:11)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB