Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call 'Static Page' to 'CMS Page' #2472

Closed
mittultechnobrave opened this issue Nov 9, 2016 · 30 comments
Closed

Call 'Static Page' to 'CMS Page' #2472

mittultechnobrave opened this issue Nov 9, 2016 · 30 comments

Comments

@mittultechnobrave
Copy link

I have installed Static Pages plugin https://octobercms.com/index.php/plugin/rainlab-pages in one of my OctoberCMS project.

Is there any way i can call one of static page to a CMS page ?

I am asking this because i have already installed one plugin called Flexi Contact https://octobercms.com/index.php/plugin/laminsanneh-flexicontact and i have modified its html form using component in one of my CMS page .. but i want the other content in the page itself from Static page .. so client can only modify from that content from there and i will show up here in my CMS page by calling that static page ..

i have tried to go viseversa by using registerPageSnippets() method in plugin which will help me to use this as a snippet and then call it into static pages, but its shows old html which is providing by plugin itself .. hence i m unable to use my updated html form there ..

Can anybody give me a clue what should i do in this scenario ?

Thanks

@artistro08
Copy link

What you need to do is grab the content in html form and put it into a content block. then call that content block with {% content 'file_name' %} simplest way i can think of

@mittultechnobrave
Copy link
Author

so you mean to say, create one static page and put some code there .. and then go to cms page and put this code on that particular page like this {% content 'file_name' %} ?

@artistro08
Copy link

Yes. but make sure its a content file in .htm format

@artistro08
Copy link

theres a section called content in the CMS backend. you want to drop the desired HTML code there

@mittultechnobrave
Copy link
Author

Ok ... i m using this plugin for your information https://octobercms.com/index.php/plugin/rainlab-pages and i have created one page called as "mypage" and then i went to CMS ==> page section and then created a new page here called as "cmspage" (cmspage.htm) and i have put this code {% content 'mypage' %} but i am getting error saying

An exception has been thrown during the rendering of a template ("The content file 'mypage' is not found.").

what am i doing wrong here ?

@artistro08
Copy link

It's because you're using a page instead of a content file. you want to use a Content file under the CMS backend. CMS => Content

@artistro08
Copy link

Should be on the left side

@artistro08
Copy link

you want to create a content file under there with the desired HTML

@mittultechnobrave
Copy link
Author

but my question is to get the content from static page which plugin provides to one of my cms page as i do not want my clients to go to CMS section as it will be tough for them to see codes over there .. are you with me ?

@mittultechnobrave
Copy link
Author

and yea one more thing .. i have one contact form plugin , this one https://octobercms.com/plugin/devinx-contactus and even if i create one content page in CMS section called as "contactformnew.htm" and put the component's code {% component 'contactForm' %} there and then create CMS page "contactnew" and put this code in markup tab {% content 'contactformnew' %} i m getting this in front output {% component 'contactForm' %} at front end as a page .. so even this case is not working for me ...

@mittultechnobrave
Copy link
Author

so actually if you understand it properly .. my scenario is actually to make my contact form https://octobercms.com/plugin/devinx-contactus work in one of my static pages which i m creating from this plugin https://octobercms.com/index.php/plugin/rainlab-pages

whether it will be getting code from CMS page to my static page which i m creating from this plugin or from partial or snippet to one of my static page of this plugin..

Additionally, this plugin already has this code in Plugins.php page

public function registerComponents()
    {
        return [
            'DevINX\ContactUs\Components\ContactForm' => 'contactForm',
        ];
    }

but when i go to static pages section and click on "Snippets" on left, i can not see any partial or snippet of this plugin .. so i m confused what should i do to achieve this thing ..

@artistro08
Copy link

Well in the pages section, there is a section for content. It comes with a WYSIWYG editor. completely hides the code. But other than that, IDK. I just started using it a few days ago and thats the best way i can think of for client management with a contact form

@mittultechnobrave
Copy link
Author

yes i can see this Content link underneath Pages section .. so what should i do in this .. i want to make my dynamic contact form to work ...

@artistro08
Copy link

The Content page under the CMS page is linked to the one in the Pages section. When you add a content block with that form, it becomes a reusable chunk of html. So you can put that content block wherever you want your form to render, and still be able to adjust the form in the backend whilst it changing every where else you put that content block.

@mittultechnobrave
Copy link
Author

ok .. i have created one content page contentstaticpage.htm and put this code into it {% component 'contactForm' %} and then i went to static pages => Add and created a new static page called as newstaticpage and added this code there {% content 'contentstaticpage' %} but in front end i m getting this output {% content 'contentstaticpage' %} ..

i am unable to see any form over there ..

@mittultechnobrave
Copy link
Author

so if you got me, i simply want my contact form to work in my static pages ..

@artistro08
Copy link

WAIT! i'm sorry, so you want to add a Partial instead of a content block. then call the partial with {% partial 'file_name' %} I'm so sorry. i get those mixed up.

@mittultechnobrave
Copy link
Author

ok so what should i code to make my contact form working in partial ?

@artistro08
Copy link

Put {% component 'contactForm' %} into a partial named "contact_form" or whatever you choose. Then create the page you want to put the contact form on (or use an existing page) and call the partial with {% partial 'contact_form' %} That should work. Wherever you put that code is where the form will appear.

@mittultechnobrave
Copy link
Author

mittultechnobrave commented Nov 10, 2016

ok let me tell you what i have done here ..

i have created a partial called as "partial-contact-form" and simply put this code {% component 'contactForm' %}

then i went to static pages and created a page called as newpage and dragged and dropped my newly created partial over there ..

Now i am able to see this form but when i click on it i am getting this error saying

Ajax handler 'contactForm::onMailSent' was not found..

@mittultechnobrave
Copy link
Author

so it means now my plugin stopped working which was working before if i put the same code {% component 'contactForm' %} in any of my CMS page ...

@artistro08
Copy link

do you have {% framework %} and {% framework extras %} in your page or layout? sounds like it's just missing the AJAX functions. I'm not sure though.

Or maybe did you copy the full code over? That's all I can think of

@mittultechnobrave
Copy link
Author

ok let me put both these codes in my static page and then my layout page which i m selecting while creating this static page ..

@artistro08
Copy link

It only needs to be in one or the other. before the ending </body> tag

@mittultechnobrave
Copy link
Author

mittultechnobrave commented Nov 10, 2016

ok .. i have put bothe the codes {% framework %} and {% framework extras %} in my static page as well as my selected layout just after my <body> tag starts

still i m having the same error saying

Ajax handler 'contactForm::onMailSent' was not found..

Additionally, even i found a code of onMailSent function from plugin itself at components/ContactForm.php

public function onMailSent()
    {
        if($this->enableCaptcha()){
            $this->formValidationRules['g-recaptcha-response'] = ['required'];
        }
        // Build the validator
        $validator = Validator::make(post(), $this->formValidationRules, $this->customMessages);

        // Validate
        if ($validator->fails()) {
            throw new ValidationException($validator);
        }

        if($this->enableCaptcha()){
            // Validate with google if setting is enabled
            if(Settings::get('enable_server_captcha_validation')){
                if(!$this->googleCaptchaPasses(post('g-recaptcha-response'))){
                    throw new ValidationException(['g-recaptcha-response' => 'Captcha credentials are incorrect']);
                }
            }
        }

        // If everything is fine - send an email
        Mail::send('devinx.contactus::emails.message', post(), function($message)
        {
            $message->replyTo(post('email'), post('name'))
                ->to(Settings::get('recipient_email'), Settings::get('recipient_name'))
                ->subject(Settings::get('subject'));
        });

        $this->page["confirmation_text"] = Settings::get('confirmation_text');
        return ['error' => false];
    }

and simply paste it in my partial page's code tab .. still having the same error saying

Ajax handler 'contactForm::onMailSent' was not found..

@artistro08
Copy link

Hmmmm. I'm at a loss here. Perhaps someone else could help?

@mittultechnobrave
Copy link
Author

mittultechnobrave commented Nov 10, 2016

can you refer this issue one of the other fellas who knows may be how to deal with this scenario .. i mean i guess someone surely have achieved this thing before.. m not the first one for sure ..

@artistro08
Copy link

I would if i could but sadly no. The devs will most likely see this. so I'd say just wait a bit and see what happens

@mittultechnobrave
Copy link
Author

hmmm .. i must say .. thanks for your great inputs ... appreciated ..

Thanks

@mittultechnobrave
Copy link
Author

Ok guys, eventually i have come up with the solution .. not the way which i wanted but somehow i am able to achieve or manage it you can say ..

So here is what i have done to make my CMS partial with having contact form working in one of my static pages ..

I went to the layout which i want to select in my static page .. i have a default layout so i just opened a file of default layout and pasted this code [contactForm] at the top of default.html so file looks like this

description = "Default Layout"


[staticPage] 
[contactForm]
==
<!doctype html>
<html>
    <head>

Then i simply go to CMS section and created one partial contact-form.htm and dragged and dropped my component into this partial ... you can always update the contact form in this partial .. which i did in my case.

Then i went to Static Page and created one static page there called as Contact us. There i have put some content which was needed from myside for this page and then simply dragged and dropped this partial into this and its working ..

Contact form is working now ..

Thank you guys for your support ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants