A
A
Adam2015-05-28 22:09:25
Drupal
Adam, 2015-05-28 22:09:25

Drupal: Is it possible to specify a link to activate a modal in a template (eg page.tpl.php)?

Welcome all.
I may be doing something wrong, please do not kick much.
I wanted to use the modal window call in the page.tpl.php template:
There is a Modal forms module (with ctools)
In one of the articles (node) I added a link to call the modal window with the form:

<p><a class="ctools-use-modal ctools-modal-modal-popup-medium" href="modal_forms/nojs/webform/43">Обратная связь</a></p>

And in principle, everything works, i.e. by clicking on this link, we get a pop-up / modal window, and a form / input fields.
But, I wanted to have this button / link in the header of the page, when clicked, we get the desired modal.
And for this, I added an entry to the page.tpl.php template in the right place, because this is just a link:
<p><a class="ctools-use-modal ctools-modal-modal-popup-medium" href="modal_forms/nojs/webform/43">Обратная связь</a></p>

As a result, we get the desired button link in the page header.
BUT! when you click on it (the link in the header), you can't see the modal, I only get the message "404 - Page not found", and
"Notice: Trying to get property of non-object in the node_page_title() function (line 2200 in the file /var/ www/user35894/data/www/test-site.smrtp.ru/modules/node/node.module)."
Although when you click on a similar link in the article, a modal window appears.
These are the things...
Good people tell me who can.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2015-05-29
@mr_ko

You have provided a link href="modal_forms/nojs/webform/43"
If you are currently on the page my_say.com/page_url and click on the link, it will go to my_say.com/page_url/+modal_forms/nojs/webform/43 and will not find anything, because such an address does not exist. If you specify href="/modal_forms/nojs/webform/43"a forward slash, then the url will always be generated like this my_site.com +/modal_forms/nojs/webform/43. you need to specify the correct url in the nref of the link.
Kinda like that. I hope you understand what I wrote here :)

E
Evgeny Pashkin, 2015-06-04
@GreedEAP

Firstly, as Alex said, a link with a slash
Secondly, you need to load the necessary js nicknames
For example, through php code

ctools_include('ajax');
ctools_include('modal');
ctools_modal_add_js();

maybe calling the last function is enough

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question