Currently hook_popups() supports two sorts of popups: ones to be generated on a particular page and ones to be generated on a particular form. However, there are other use cases that might require more flexibility. For example, a popup to edit a node title. Here we would need to be able to add this popup to any node being displayed.
How best to approach this? One way might be to emulate what actions does with hooks.
'hooks' => array(
'nodeapi' => array('presave'),
'comment' => array('insert', 'update'),
),
Obviously this sort of data can't easily be encoded in an array key like a path or form id can. But we could do something like this:
function mymodule_popups() {
$items = array();
$items['my/path'] = array(
'#my-id',
);
// Numerical index for other than paths and form ids.
$items[] = array(
'#my-other-id' => array(
'#hooks' => array(
'nodeapi' => array('view'),
),
),
);
return $items;
}
Comments
Comment #1
starbow commentedI am having trouble wrapping my brain around this one.
For something like editing a node title, I think we are better off trying to get edit-in-place going, vs moving it into a popup.
Can you give me another use case or two?
Comment #2
sunilchai commentedHi ,
I had a button and when ever i click on the button i want the popup to be enabled with some form and fileds.
Is that possible using the pop up module?? if so how can i achieve that.
hoping for the earliest reply,
Thanks and regards,
sunilchai..
Comment #3
2ndChanceTech commentedWouldn't it be possible to simply have custom form templates, that are limited to just the fields you want, then have popup dialogs load the form using that template?
Haven't tried in 6, but it was possible in 5x with hook_form_alter. You could then just create a .tpl that contains the fields you need editable.
It's a good amount of work, but probably the only way to do per field editing in a pop-up (atleast that's how it was done in 5.x)
Comment #4
scottrigbyHi starbow,
Re #1, another use case would be when a module adds a link to node->$links
For instance, I made a small module that adds a link to create a child content type in the $links of a parent content type.
In order to get the popup functionality working the way I want, I borrowed from popups_admin.module, and played with some of the Options from the README. However I can only do this on a per-path basis. This is how I got it to work on node/2:
Unfortunately it doesn't seem to work with something like:
Which I would need in order to get this to work on all nodes that contain this string.
This is why my issue seems to relate to nedjo's original support request - because it needs to apply to any node being displayed.
Does this make sense? Is there another way to do this?
Comment #5
starbow commented@scottrigby: it is both exciting and humbling to see all the ways people want to use this module that I never considered :)
How about something like:
Comment #6
scottrigbyhi starbow -- thanks!
Ok, I tried this code in my custom module -- and I just get a blank white screen :?I've been trying to see where there may be some error and so far can't find it :(
If you have any time to look at this again, I'd appreciate it -- This would be really great to get working :)
Edit: sorted :) See below...
Comment #7
scottrigbyok, got it :p
And guess what? it works!
Comment #8
scottrigby@ starbow: Is there a way to use wildcards when specifying the path of the link?
So instead of:
something like this?
Where $n is either a node of a particular type, a child of the current node, or something else. Is something like this possible?
Comment #9
starbow commentedI am glad that worked for you.
Wildcards are not currently supported. Feel free to open it as a new feature request.
Comment #10
starbow commentedI have added a single wildcard in rc6. '*' means all pages. Not as clean as a new hook, but it works and it is simple.
scottrigby: This do not address your request. Rereading #8, I actually don't know what you are asking for. And a new issue thread is definitely a better place to discuss it.
Comment #11
scottrigbyHi Starbow - great that you were able to add this :)
To clarify #6... (at least the part that relates to this issue):
* In popups_admin.module (from popups-6.x-1.1-rc5), on line 29 is the first instance of specifying a popup based on the link path:
'#tabs-wrapper a[href$=admin/build/block/add]', // Add BlockBuilding upon your nodeapi support, what I was hoping is to be able to give a wildcard to a link path, so if I have a list of nodes on a certain page such as node/2, node/35, node/10... etc, we could specify a popup on all of these links by writing something like this:
'a[href$=node/*]', // view nodeThis is just a generic example. But it sounds like the wildcard you just added would do the trick for this? Could you clarify how this wildcard is used if different than the example just above? :)
Comment #12
starbow commentedThe wildcard I have introduced is for adding the rule to the page.
What you want is 'a[href^=node/]'
You should look at the docs for jQuery selectors: http://docs.jquery.com/Selectors/attributeStartsWith#attributevalue