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...

AttachmentSize
nodewords_panels2_integration.patch4.94 KB

#1

davexoxide - October 1, 2007 - 19:50

Here's the Panels patch

http://drupal.org/node/180061

#2

davexoxide - October 2, 2007 - 14:33

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

davexoxide - October 2, 2007 - 14:44

The recent panels upgrade passes the panel object.

This patch accepts works with that upgrade.

AttachmentSize
nodewords_panels2_integrations_01.patch5.2 KB

#4

davexoxide - October 2, 2007 - 15:51

This patch adds help text to the form which explains how to pass arguments from the URL into your Meta Tags.

AttachmentSize
nodewords_panels2_integrations_02.patch6.51 KB

#5

s.Daniel - December 30, 2007 - 18:14

subscribing

#6

sirkitree - January 14, 2008 - 16:04

+1

Panels2 is now beta. It'd be great if the maintainer could look into this patch now.

#7

rastarr - January 15, 2008 - 05:46

Subscribing hoping this module gets updated for Panels :)

#8

Robrecht Jacques - January 15, 2008 - 07:46

Did you try the patch? Does it work like expected? Thanks.

#9

davexoxide - January 22, 2008 - 00:04

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

davexoxide - January 23, 2008 - 17:27

Here's the newest patch. Tested and seems to be working just fine w/ Panels 1 and Panels 2

AttachmentSize
nodewords_panels2.diff3.78 KB

#11

Robrecht Jacques - January 24, 2008 - 21:13

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

Robrecht Jacques - January 29, 2008 - 14:34
Version:HEAD» 5.x-1.x-dev

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

Robrecht Jacques - January 29, 2008 - 14:35
Version:5.x-1.x-dev» 5.x-1.8-rc1

#14

patchak - May 28, 2008 - 22: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

Summit - August 12, 2008 - 07:54

Hi,
Is this panels-argument patch in metatags 1.9?

thanks in advance for your reply!

greetings,
Martijn

 
 

Drupal is a registered trademark of Dries Buytaert.