2

I want to display node add form of a particular content type in a pop-up for anonymous users too. There are posts related to displaying a node content in pop-up but not about node add form.

I have a .tpl for a calendar display view. Now when anyone click on a particular div of the table I need to open a pop-up of node add form. So I need to add the <a> anchor tag in the tpl file.

How to achieve this? Is there a way to call the node add form as a pop-up in jquery?

0

2 Answers 2

0

First, I would say dont put this logic in a .tpl if you can put it somewhere else, for maintainability.

Second, as with many drupal solutions, there is more than one way and they differ in some aspects. Let me try a few for you:

Solution A: https://www.drupal.org/project/colorbox This adds a checkbox to the views field controls that says "Open link in Colorbox", and you use the Output as a Link controls to make this link point to /node/add. Verify necessary permissions are set.

Solution B: Ctools modal link conversion. In your calendar view add a nid field and use the 'Rewrite Field' options to replace it's value with your Create anchor tag. Make sure this tag has the class "ctools-use-modal". The reason for doing this so early is that links tagged with that class, when passed through the render process, get converted into a modal link. Since this is on a calendar display, I am guessing that you are wanting people to make events for the calendar, and it would be really cool to have the event creation form pre-populate with the day they clicked? Look at https://www.drupal.org/project/prepopulate and alter your anchor path to include the token from the date field that is already in your view. Now the hard part, you will need to write a hook, so you will need a custom module. I havent tried https://www.drupal.org/node/1312770 but it looks like it can make a skeleton for you.

You will need to implement this:

function hook_views_pre_build(&$view) {
  if ($view->name == [your_view_here]) {
    $current = $view->current_display;
    // Include the CTools tools that we need.
    ctools_include('ajax');
    ctools_include('modal');
    // Add CTools' javascript to the page.
    ctools_modal_add_js();
  }
}

That will make sure the view is processed by ctools looking for modal pop-ups. I just used this the other month in a slightly more complicated use case, where path in the view is a custom registered callback and anonymous user gets a sign-up form in modal, and logged in user gets the requested resource. Using what I have explained above, you should have a site where everybody gets the modal. Make sure you have the appropriate Node Create permissions checked.

Solution C: There is an Overlay module that ships with Drupal 7, has been in there from the begining. This is less popular than colorbox and ctools, and bit more limited. Enable the module, give anon user permission to use it, and add "#overlay=" to the beginning of your link path in the view. I dont recall at the moment if they solved some security issue involved with anonymous access to this module, so I caution against using it. I am really only including it here as an example of how many solutions are available in drupal.

Good luck, and please do say how this worked for you.

0

Install lightbox module then add

rel='lightbox'

To the a tag as a property. I mean

<a rel='lightbox' href='node add form link'>some text </a>

Anything can be displayed as a nice smooth popup by lighbox. Forms,slideshow,gallery and ... can be displayed by lightbox.