Globals and weblogs in Freeform? 
Posted: 06 July 2007 10:28 AM   [ Ignore ]
Jr. Member
RankRank
Total Posts:  50
Joined  2007-04-30

So many questions…

Should I be able to use global and weblog variables within the freeform:form tag?  Basically need to build some dropdowns using {exp:weblog:entries} tag, and do some segment checking {if seg_2 == “whatever"}....

Tried, but the template stops loading once it hits these tags.

Profile
 
 
Posted: 06 July 2007 09:35 PM   [ Ignore ]   [ # 1 ]
Jr. Member
RankRank
Total Posts:  50
Joined  2007-04-30

Well, nope.

I tried all combinations of using weblog tags, exp:query tags, assigning variables, php outside and inside of the freeform tag with no luck.

FYI, in the end, the only solution I managed to get working was creating new templates to hold the weblog and query tags I needed, and used embeds within the freeform tag, and all is well and right in the world again.

Ira

Profile
 
 
Posted: 09 July 2007 03:34 AM   [ Ignore ]   [ # 2 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

You can certainly use subtemplates / embeds, but you should also be able to nest Freefrom with {exp:weblog:entries}, I don’t see why not.

 Signature 

Ingmar Greil

Profile
 
 
Posted: 09 July 2007 04:50 AM   [ Ignore ]   [ # 3 ]
Jr. Member
RankRank
Total Posts:  50
Joined  2007-04-30

I’m not sure why it wouldn’t work, but nesting weblog or query tags within the Freeform tag just didn’t work for me.  It worked when I nested FF within a weblog tag but I required multiple weblog tags for different dropdown fields.

Actually, as I’m typing this, I realized I probably could have called multiple weblogs from the same weblog:entries tag using the pipe character, and placed that around the FF tag… Anyhoo, the embeds are actually working very well as is.

As usual, thanks for the info!

Profile
 
 
Posted: 09 July 2007 05:13 AM   [ Ignore ]   [ # 4 ]
Sr. Member
Avatar
RankRankRankRank
Total Posts:  336
Joined  2005-07-09

Ah yes, I assumed you would be doing it that way, yes:

{exp:weblog:entries}
{exp
:freeform:form}

....

{/exp:freeform:form}
{
/exp:weblog:entries}

But the important thing is you got it to work smile

 Signature 

Ingmar Greil

Profile
 
 
Posted: 09 July 2007 05:18 AM   [ Ignore ]   [ # 5 ]
Jr. Member
RankRank
Total Posts:  50
Joined  2007-04-30

I’m a designer, and not a programmer, so assume that the problem lays between my keyboard and my chair when it comes to this stuff!  wink

Profile
 
 
Posted: 02 October 2007 10:52 AM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  7
Joined  2007-08-27

I have a variant, I think, on this question.

I’d like to use a {exp:weblog:entries} tag to populate a select box in the freeform. But nothing works, not even an embed.

Here’s what I’ve got:

{exp:freeform:form form_id="contact-form" form_name="contact" required="subject" notify="me@mywebsite.net" template="contact" return="contact/thank-you/%&#xen;try_id%%/"}
  
<fieldset>
<
legend>Pick a subject</legend>
   <
p><strong>Note</strong>: All fields are <em class="required">required</em>.</p>
<
ol>
<
li class="required">
  <
label for="form-subject"><em>*</em>Subject</label>
  <
select id="form-subject" name="subject" required="required">
<
option value="">Select a subject</option>
<
option value="Marketable securities funds">Marketable securities funds</option>
{embed="contact-dropdown"}
<option value="Corporate information">Corporate information</option>
<
option value="Other">Other</option>
  </
select>
</
li>
</
ol>
   <
input type="hidden" name="submit" value="Submit" />
   <
button type="submit">Submit<em></em></button>
  </
fieldset>
{/exp:freeform:form}

Where the embedded file is:

{exp:weblog:entries weblog="fund" category="5" sort="asc" orderby="url_title" disable="member_data|pagination|trackbacks"}
<option value="{title}">{title}</option>
{/exp:weblog:entries}

I’d like for those titles to populate the select box. How did you manage to get yours working, Ira?

PS: I tried nesting freeform within {exp:weblog:entries}, but that gives me multiple contact forms, one for each title in my weblog.

Profile
 
 
Posted: 02 October 2007 12:17 PM   [ Ignore ]   [ # 7 ]
Jr. Member
RankRank
Total Posts:  50
Joined  2007-04-30

Hey there,

It’s been a while, but I think in the end that I couldn’t get it to work, no matter where I placed the exp:weblog tags, inside freeform, outside, or embed. What DID work for me is using the query tag in the embed, instead of the weblog tag.  Here’s what I did:

Within the freeform, add an embed tag like this (ex: for a dropdown field):

<select name="event_name">
  <
option value="">Please select...</option>
  
{embed="my_templategroup_name/my_template"}
</select>

I created a template group, and template.  In the template, I had to use an {exp:query....} tag, as the {exp:weblog...} tag wouldn’t parse.  Here’s that template:

{exp:query sql="SELECT title, entry_id FROM exp_weblog_titles WHERE weblog_id = '31' AND status='open'  ORDER BY title"}
  
<option value="{title}">{title}</option>
{/exp:query}

That’s the general idea anyway.  This builds a select list using the entry titles from all open entries in the weblog with an ID of 31.

(My actual code is a little more complexe than above, as I’m also reading the url segments to check for an entry ID, and having the dropdown preselected if there is one...)

If that’s not clear, just drop me a line here, and I’ll try to clarify.

Cheers,

Ira

Profile
 
 
Posted: 02 October 2007 01:28 PM   [ Ignore ]   [ # 8 ]
Newbie
Rank
Total Posts:  7
Joined  2007-08-27

Alright, man, that worked!

Cheers to you, sir!

Profile
 
 
Posted: 02 October 2007 01:30 PM   [ Ignore ]   [ # 9 ]
Jr. Member
RankRank
Total Posts:  50
Joined  2007-04-30

No worries, glad you got it working!

Ira

Profile
 
 
Posted: 14 May 2008 03:10 AM   [ Ignore ]   [ # 10 ]
Newbie
Rank
Total Posts:  12
Joined  2008-04-08

Just to add to this - I tried embedding from the same template group as my freeform form, but this wouldn’t work. Instead, I embedded from a different template group and all is well. This might bear mentioning for other people having similar difficulties.

Profile