0

I made a plugin of a contact form that will be include in a page.

Actually, the page is call like this:

myurl/en/pageHeader/pageParent/contact/

As the cms is made of dynamic content, the url can change, depending of where the user wants to put the contact plugin or the page containing the plugin.

And here is my question, I want to pass a specific parameter to my url in order to fill a label of my form.

But, I don't figure out how pass this parameter, or in simpler words: I don't understand how to access the url where the plugin is.

So I have a basic architecture:

djangocms_plugin:
  -migrations
  -__init__.py
  -admin.py
  -api.py
  -cms_plugins.py
  -forms.py
  -middleware.py
  -models.py
  -urls.py
  -views.py

And in my url:

# -*- coding: utf-8 -*-
from django.conf.urls import patterns, url
from djangocms_partner.views import view_partner_contact

urlpatterns = patterns(
  '',
  url(r'^$', view_partner_contact, name='view_partner_contact'),
)

and the views.py:

# -*- coding: utf-8 -*-
import json
from django.http import HttpResponse

import logging

def view_partner_contact(request):
  logging.info("\n\n COUCOU \n\n")

So as you can see, I simply try to figure out "how to access this".

Otherwise, I don't see how I could get the information providing for a previous page (directly link to this page, containing the plugins).

At the moment, this does nothing.

Thanks for the time spent on reading it.

Jay Cee
  • 1,855
  • 5
  • 28
  • 48

1 Answers1

0

I think you might be better off passing in parameters from the URL to views.py instead of forms.py, which this question does a good job of answering how to do. Typically, your View passes your Form into your Template.

Community
  • 1
  • 1
Jordon Birk
  • 480
  • 1
  • 9
  • 28
  • Well, my main problem is how to know that I am in the page owning the plugin? Passing or getting a parameter isn't a problem.. But the folder tree I am showing is the plugin's one. Not the app one, and from here I don't succeed on showing anything from my view. – Jay Cee Apr 14 '16 at 09:28
  • Why not have a form "POST" with the parameters to the page you're directing to, then have that current view "GET" to see if it's the right parameters from the page you're looking for? – Jordon Birk Apr 14 '16 at 13:41