Support » Fixing WordPress » Contact Form 7 Nested Shortcode

  • ragretail

    (@ragretail)


    Silly question & I bet there’s a simple answer.

    I’m trying to contain my CF7 inside an existing [contentblock].

    From some online research I seem to understand I need to create ‘nested shortcodes’ but I’m only guessing.

    The code on the site for the content block is:
    <div class=”text-center”>
    <p class=”pretitle”>
    [cols]
    [col class=”1″]
    [pcontentbox icon=”fa fa-envelope” title=”Contact Us”]
    [/col]
    [/cols]
    </p>
    </div>

    I’m trying to add the CF7 inside it:
    [contact-form-7 id=”2878″]

    But this doesn’t work:
    <div class=”text-center”>
    <p class=”pretitle”>
    [cols]
    [col class=”1″]
    [pcontentbox icon=”fa fa-envelope” title=”Contact Us” [contact-form-7 id=”2878″]]
    [/col]
    [/cols]
    </p>
    </div>

    This doesn’t work:
    <div class=”text-center”>
    <p class=”pretitle”>
    [cols]
    [col class=”1″]
    [pcontentbox icon=”fa fa-envelope” title=”Contact Us” contact-form-7 id=”2878″]
    [/col]
    [/cols]</p>
    </div>

    This doesn’t work:
    <div class=”text-center”>
    <p class=”pretitle”>
    [cols]
    [col class=”1″]
    [pcontentbox icon=”fa fa-envelope” title=”Contact Us”] [contact-form-7 id=”2878″]
    [/col]
    [/cols]
    </p>
    </div>

    how do I get the CF7 inside the contentbox?

    Thank you.

    The page I need help with: [log in to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    Where did you get this “contentbox” shortcode? Internally, it needs to take the content it’s received via the $content parameter and execute a “do_shortcode” on it before returning it to the caller.

    ragretail

    (@ragretail)

    The contentbox short code was within the original theme template.

    You kind of lost me on the other bits, whats the ¢content paramater & how to I execute “do_shortcode”?

    Thank you.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    It seems that theme is no longer available on Themeforest. You need to contact the theme’s developer to make a code change (or find out if there’s a workaround to that).

    ragretail

    (@ragretail)

    Oh, would the files be in the ThemeEditor?
    If so, what might I search for or in what file might it be to then edit it?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    I have no idea about that theme. As it’s a commercial theme, we really don’t support it here.

    Commercial products are not supported in these forums.

    ragretail

    (@ragretail)

    Oh OK sorry I didn’t realise.

    By the way, I found the shortcode file in the Theme Editor.

    If it’s not too much trouble to advise how I change it to execute “do_shortcode” it would be greatly appreciated but understand if you can’t help.

    Thank you.

    class MaThemeShortcodeContentbox extends MaThemeShortcode {
    
    	public function __construct($master) {
    		parent::__construct($master);
    		$this->trigger = "pcontentbox";
    		$this->group = esc_html__("CONTENT",'MikeAvetyan Theme/Plugin');
    		$this->name = esc_html__("Content Box",'MikeAvetyan Theme/Plugin');
    		$this->description = esc_html__("Add a styled Content Box",'MikeAvetyan Theme/Plugin');
    		$this->fields = array(
    							  "icon" =>				
    								array(
    									"label"=>esc_html__("Page icon",'MikeAvetyan Theme/Plugin'),
    									"type"=>"Select",
    									"options" => ma_theme_font_awesome_icons(),
    									"description"=>esc_html__('Select icon that will be assigned to this service. For icons overview, Google "Font Awesome".','MikeAvetyan Theme/Plugin'),
    									"default"=>"hide"
    								),
    							  "title" =>
    							  array(
    									"label" => esc_html__("Title",'MikeAvetyan Theme/Plugin'),
    									"type" => "Text",
    									"description" => esc_html__("This should be a content box title.",'MikeAvetyan Theme/Plugin'),
    									"default" => esc_html__("Address",'MikeAvetyan Theme/Plugin')
    									),
    							  "description" =>
    							  array(
    									"label" => esc_html__("Description",'MikeAvetyan Theme/Plugin'),
    									"type" => "TextArea",
    									"description" => esc_html__("This should be a content box description.",'MikeAvetyan Theme/Plugin'),
    									"default" => esc_html__("Our Office <br> 74th St Between <br> United States",'MikeAvetyan Theme/Plugin')
    									),
                                   "button_type"=> 
    							  array(
    									"label" => esc_html__("Button Type",'MikeAvetyan Theme/Plugin'),
    									"type" => "Select",
    									"description" => esc_html__("Select the type of button required. The type determines the button color",'MikeAvetyan Theme/Plugin'),
    									"options" => 
    									array(
    										  esc_html__("Outline Light",'MikeAvetyan Theme/Plugin') => "btn-outline-light",
    										  esc_html__("Outline",'MikeAvetyan Theme/Plugin') => "btn-outline",
    										  esc_html__("Contour",'MikeAvetyan Theme/Plugin') => "btn-contour",
    										  ),
    									"default" => "btn-outline"
    									),
                                  "button_size"=> 
    							  array(
    									"label" => esc_html__("Button Size",'MikeAvetyan Theme/Plugin'),
    									"type" => "Select",
    									"description" => esc_html__("Select the type of button required. The type determines the button size",'MikeAvetyan Theme/Plugin'),
    									"options" => 
    									array(
    										  esc_html__("Small",'MikeAvetyan Theme/Plugin') => "btn-small",
                                              esc_html__("Medium",'MikeAvetyan Theme/Plugin') => "btn-medium",
    										  esc_html__("Large",'MikeAvetyan Theme/Plugin') => "btn-large",
    										  esc_html__("Big",'MikeAvetyan Theme/Plugin') => "btn-big",
    										  ),
    									"default" => "btn-medium"
    									),
    							  "button_url" =>
    							  array(
    									"label" => esc_html__("Button Url",'MikeAvetyan Theme/Plugin'),
    									"type" => "Text",
    									"description" => esc_html__("Enter the destination url of the button",'MikeAvetyan Theme/Plugin'),
    									"default" => "#"
    									),
    							  "button_label" =>
    							  array(
    									"label" => esc_html__("Button Label",'MikeAvetyan Theme/Plugin'),
    									"type" => "Text",
    									"description" => esc_html__("Enter the button label here. Leave this field blank to hide the button",'MikeAvetyan Theme/Plugin'),
    									"default" => "Learn More" 
    									)
    							  );
    		// add block level cleaning
    		maTheme()->shortcode->blockLevel[] = $this->trigger;
    	}
    
    	public function output($atts,$content=null,$code="") {
    		extract($atts);
    
    		$html = "
    			 <!-- Content Box -->
                       <div class='animated' data-animation='bounceIn' data-animation-delay='200'>
                           <div class='content-box text-center'>
                             <i class='$icon'></i>
                            <h4>$title</h4>
                             <div class='seperator mini'><span></span></div>
    						<p>$description</p>
                              <a href='$button_url'>$button_label</a>
                              </div> <!-- End Content Box -->
    					</div> <!-- End Column 4 -->";
    
            return trim($html);
    	}
    
    }
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    WEll, try this… change that last line to

    return trim( do_shortcode( $html ) );

    ragretail

    (@ragretail)

    OK, thank you. Added, but then do what on the ‘page’?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    That should allow the contentbox shortcode to expand any shortcodes entered within it.

    ragretail

    (@ragretail)

    Thats a shame, it didn’t work.

    http://www.rag-retail.com/#contact-us

    <div class=”text-center”>
    <p class=”pretitle”>
    [cols]
    [col class=”1″]
    [pcontentbox icon=”fa fa-envelope” title=”Contact Us” [contact-form-7 id=”2878″]]
    [/col]
    [/cols]</p>
    </div>

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    That’s not going to work, no how.

    It would work in this situation:

    [shortcodeX] some content [contact-form-7 id=”2878″][/shortcodeX]

    Sorry, but that’s about all I can suggest. Try writing that shortcode that way.

    ragretail

    (@ragretail)

    OK, thank you for you help. Can’t get it to work. Not sure what I’m doing wrong.
    Thank you all the same as you’ve been very patient with me.

    ragretail

    (@ragretail)

    So just to confirm,

    On the last line of the [pcontentbox] shortcode should be;
    return trim( do_shortcode(“[contact-form-7 id=”2878″]”) );

    On the ‘page’ should be;
    [pcontentbox icon=”fa fa-envelope” title=”Contact Us”][contact-form-7 id=”2878″][/pcontentbox]

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    >> On the ‘page’ should be;
    [
    I didn’t say that at all. I don’t know how the shortcode works. We cannot support that theme here.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Contact Form 7 Nested Shortcode’ is closed to new replies.