We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Not pulling content like I thought it would......

How Do I?

newdev's avatar
newdev
3 posts
8 years ago
newdev's avatar newdev

Here is what I am doing. I’m coming from WordPress which has made me lazy on spotting the easy tag errors. But I’m determined to get good at this. I’m trying to visualize how the channel vs post vs template vs. page relate not in the Wordpress mindset.

I have a Freeform form that works in that when they user clicks submit, the admin receives an email and it registers in Freeform. Yea!

I’m trying to direct the user to a page using the return= that says “thanks, etc etc.” I thought this would be easy. Within my template group called “signup” I created another template called thanks1 using the index of the signup group as my template. I deleted the freeform tags from my new thanks1.html and left everything else.

On the “signup” template index.html (form page) that I copied for my thanks the url_title=”{segment_1} and it pulls content from content/static pages/content title

on the thanks1.html (renamed clone of signup/index.html) I added the thanks1 so it reads url_title={segment_1}{thanks1} (the name of my template group and content name) I thought it would just pull the page_content from whatever my title was….??

The text content (“please leave us your info to be added tor our waiting list….) is under my Content/static pages/signup and happily is displayed on my signup template page. I created my desired content also under content/static pages called thanks1. When a user submits, it still goes to the original content “please leave us your infor to be added for our waiting list….” not my newly created thanks1 template with the thanks1 content.

If it can’t find my page then I should get a 404 which I am not.

MY new thanks1 template: (remember sits alongside my signup template which I want to pull from content/static_pages/thanks1 but its not)

{exp:channel:entries
 channel="static_pages"
 dynamic="no"
 url_title="{segment_1}thanks1"
 status="open"
 disable="categories|category_fields|member_data|pagination"
}{if no_results}{redirect="404"}{/if}
{embed="home/_html-wrapper"
 entry_id="{entry_id}"
 css=""
 js_skin=""
 js_main=""
 layout=""
 body_class=""
 wrapper_class="subpage"
}
{exp:stash:set name="breadcrumbs"}
<div class="breadcrumbs">
 <ul>
  <li class="home">
   <a href="http://{homepage}" title="Go to Home Page">Home</a>
   <span>/ </span>
   <strong>{title}</strong>
  </li>
 </ul>
</div>
{/exp:stash:set}
{exp:stash:set name="main_content"}
<div class="std"> </div>
<div>
 <div class="page-header">
  <div class="header-items">
   <div class="page-title">
    <h1>{title}</h1>
   </div>
  </div>
 </div>
</div>
<div class="page-content main-content-full">
 <div class="text">{page_content}</div>

  
</div>
{/exp:stash:set}{/exp:channel:entries}

My orginal signup index.html template (which happily pulls content from content/static_pages/signup)

{exp:channel:entries
 channel="static_pages"
 dynamic="no"
 url_title="{segment_1}"
 status="open"
 disable="categories|category_fields|member_data|pagination"
}{if no_results}{redirect="404"}{/if}
{embed="home/_html-wrapper"
 entry_id="{entry_id}"
 css=""
 js_skin=""
 js_main=""
 layout=""
 body_class=""
 wrapper_class="subpage"
}
{exp:stash:set name="breadcrumbs"}
<div class="breadcrumbs">
 <ul>
  <li class="home">
   <a href="http://{homepage}" title="Go to Home Page">Home</a>
   <span>/ </span>
   <strong>{title}</strong>
  </li>
 </ul>
</div>
{/exp:stash:set}
{exp:stash:set name="main_content"}
<div class="std"> </div>
<div>
 <div class="page-header">
  <div class="header-items">
   <div class="page-title">
    <h1>{title}</h1>
   </div>
  </div>
 </div>
</div>
<div class="page-content main-content-full">
 <div class="text">{page_content}</div>

 {exp:freeform:form
  form_name="exclusive-signup"
  form:id="exclusive-signup-form"
  return="{segment_1}/thanks1"
  notify="[email protected]"
 }
 <fieldset>
  <ul class="form-list">
   <li>
    <label>First Name</label>
    <div class="input-box">
     <input class="input-text" type="text" maxlength="150" id="freeform_first_name" value="" name="first_name">
    </div>
   </li>
   <li>
    <label>Last Name</label>
    <div class="input-box">
     <input class="input-text" type="text" maxlength="150" id="freeform_last_name" value="" name="last_name">
    </div>
   </li>
   <li>
    <label>Email</label>
    <div class="input-box">
     <input class="input-text" type="text" maxlength="150" id="freeform_email" value="" name="email">
    </div>
   </li>
   <li>
    <label>Message</label>
    <div class="input-box">
     <textarea class="textarea" id="freeform_user_message" rows="6" cols="50" name="user_message"></textarea>
    </div>
   </li>
   {if freeform:captcha}
   <li>
    Please enter the word you see in the image below:
    <div class="input-box">
     {freeform:captcha}
     <input type="text" name="captcha"  />
    </div>
   <li>
   {/if}
   <li class="buttons-set">
   <button class="button" type="submit"><span><span>Sign Up</span></span></button>
   </li>
  </ul>
 </fieldset>
 {/exp:freeform:form}
</div>
{/exp:stash:set}{/exp:channel:entries}
       
Rob Allen's avatar
Rob Allen
2,950 posts
8 years ago
Rob Allen's avatar Rob Allen

Ok that’s a lotta stuff t take in so I’ll try and simplify it a bit.

For the template where you have your form there are two ways to show a “thanks” message:

  1. Use a thanks.html template
{exp:freeform:form
  form_name="exclusive-signup"
  form:id="exclusive-signup-form"
  return="{segment_1}/thanks1"
  notify="[email protected]"
 }

So in this case {segment_1} will be your template group name, and thanks1 a template inside that group.

Example: if my template group is called “signup” the form will redirect to /signup/thanks1 and display whatever content is in the thanks1 template.

  1. Using a conditional and the same index template to show thanks message
{if segment_2 != "thanks"}
{exp:freeform:form
  form_name="exclusive-signup"
  form:id="exclusive-signup-form"
  return="{segment_1}/thanks"
  notify="[email protected]"
 }
{/if}

{if segment_2 == "thanks"}
  Thanks for posting!
{/if}

In this example you’d use the same template the form is in, but use a segment value to change the content. Put simply if {segment_2} contains the word “thanks” it shows the thank you message, otherwise it shows the form.

Does that make things any clearer?

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
8 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

Also adding require_entry=”yes” to your channel entries should make that 404 work.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.