Panels Integration w/ argument handling
davexoxide - October 1, 2007 - 19:48
| Project: | Meta tags |
| Version: | 5.x-1.8-rc1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (code needs review) |
Description
I needed to add nodewords support to Panels 2.
There are 2 patches required.
1 for nodewords (attached)
1 for Panels
Mild modification should make it work with Panels v1.
Arguments are parsed from the URL and can be replaced in your meta tags by using %0,%1,%2...
| Attachment | Size |
|---|---|
| nodewords_panels2_integration.patch | 4.94 KB |

#1
Here's the Panels patch
http://drupal.org/node/180061
#2
In reference to the post above. DO NOT USE THAT PATCH.
Since Panels Alpha 11 the ability to pass panel information into modules is possible.
#3
The recent panels upgrade passes the panel object.
This patch accepts works with that upgrade.
#4
This patch adds help text to the form which explains how to pass arguments from the URL into your Meta Tags.
#5
subscribing
#6
+1
Panels2 is now beta. It'd be great if the maintainer could look into this patch now.
#7
Subscribing hoping this module gets updated for Panels :)
#8
Did you try the patch? Does it work like expected? Thanks.
#9
There is a new release of this module, the code is there to recognize which version of panels is being used. But it doesn't seem to have a form_alter that puts the meta tags fields inside the Panels form.
I will be checking out head this week to see if I can create a patch for this feature.
New version also did not include argument handling. I'll submit a patch for that as well when I get the above completed.
#10
Here's the newest patch. Tested and seems to be working just fine w/ Panels 1 and Panels 2
#11
Aha, now I understand what you were doing :-)
Some comments though:
1. Why not make:
<?php+ if ($result = db_fetch_array(db_query("SELECT * FROM {panels_page} WHERE did = '%d'", $panel_id))) {
+ return array('type' => 'panels', 'ids' => array($result['did']));
+ }
?>
part of
_nodewords_detect_type_and_ids(). In fact, isn't that already part of this?2. Then
<?php+ /* Panels are tricky so lets do this */
+ if ($type = 'panels' && isset($ids)) {
+ $result = _nodewords_panels_load($ids);
+ $type = $result['type'];
+ $ids = $result['ids'];
+ }
?>
doesn't seem needed.
3. The problem with the form ids that have changed is correct. Will fix that.
4. I suppose
<?php+function nodewords_panels_pre_render($panel_id = NULL) {
+ $tags = nodewords_get('panels', $panel_id->did, TRUE);
+ foreach ($tags as $name => $content) {
+ if (!empty($content)) {
+ $argument = nodewords_get_arguments();
+ foreach ($argument as $key => $phrase) {
+ $content = str_replace('%'.$key, ucwords($argument[$key]), $content);
+ }
+ if($name != 'robots'){
+ drupal_set_html_head('<meta name="' . $name . '" content="' . $content . '" />');
+ }
+ }
+ }
+}
?>
is a call for a hook of panels. But how is this going to work? Would one not have two occurences of the meta tags on panel pages?
I'd prefer some more general solution for arguments. Eg I suppose views also could have arguments. Maybe
_nodewords_detect_type_and_ids()should return a array with'type','ids'AND'arguments'. In_nodewords_prepare()one could then do:<?php+ $argument = nodewords_get_arguments();
+ foreach ($argument as $key => $phrase) {
+ $content = str_replace('%'.$key, ucwords($argument[$key]), $content);
+ }
?>
I'll look into this again tomorrow ... If my comments don't make sense, please tell me.
#12
The argument part has not been added, the edit panel_pages part (form_ids etc) has.
Please test 5.x-1.8-rc1 and give feedback. Please test whether you can assign meta tags, whether they show up where you expect them to show up and whether, if you delete the panel, the tags are deleted too.
Once enough people test this, I can look at arguments.
Thanks!
#13
#14
Humm hey there I just added an meta info to a regular panel page and it does not seem to "save" the info, since when I check out the source, after clearing the cache, I can't see the meta info actually loading at all. It does work for views tho, but not for panel pages. It does not throw any error, but just does not seem to actually use the info I add there.
I just upgraded to panels beta4 so maybe that's why....
Patchak
#15
Hi,
Is this panels-argument patch in metatags 1.9?
thanks in advance for your reply!
greetings,
Martijn