Spread doesn't appear for pages on more than 1 URL level

bluepen - July 6, 2009 - 18:27
Project:Spread
Version:6.x-1.0
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi. I find that Spread shows up without JavaScript AND only on root.com/page, not on root.com/category/page.
Is this something to do with my site, or is there something I can change in the .module for this?

Thanks so much, I'm still new to this.

#1

jchatard - July 7, 2009 - 06:57

Hi bluepen,

You can show Spread block on every url you want, to achieve this you need to configure the block visibility settings properly, I let you check this documentation page on howto do so: http://drupal.org/handbook/modules/block

And I let you close the issue when you're done.

Jérémy

#2

bluepen - July 7, 2009 - 12:13

Hey Jérémy,

Thanks for the reply.

I've set the block visibility to "Show on every page except the listed pages." (empty field below), didn't specify any roles to view, and "Users cannot control whether or not they see this block.".

Just to recap and clarify, I created a region in theme.info called "spreadform", and then I did

<?php
if($spreadform):
?>

<?php
print $spreadform;
?>

<?php
endif;
?>

in node-story.tpl.php and nothing shows up. But I entered the same in page-node-123.tpl.php and it did show.
I've checked the permissions and moved the Spread block into that "spreadform" region.

Not sure if I'm doing it correctly. Thanks so much for your help, I realize this is probably basic troubleshooting and not to do with the build of the module.

#3

jchatard - July 7, 2009 - 12:25

From what you write, this "seems" to be logical. Let me explain.

When you add a region in the .info file, this region will be available for all your page*.tpl.php as long as these templates do a print of $spreadform. This what you did for page-node-123.tpl.php. So visiting the node which nid is 123 will render page-node-123.tpl.php and shows the spreadform. But spread form won't show up on any other URL/page/etc. since page-node-123.tpl.php is only called for the node 123. In such cases, standard page.tpl.php is rendered. So you need to add the region $spreadform on page.tpl.php too is you wish to render the form on other pages.

And remember that node-story.tpl.php is node template, as such it does not contain any region. Will will never be able to render a region inside a node template (that's not true, but is simplier for your understanding).

Hope it helps!

Jérémy

#4

bluepen - July 7, 2009 - 13:59

Thanks so much! The Spread form now shows and works, although it doesn't look like javascript, looks like just a regular form. But that doesn't matter, I'll try and style it a bit.

I honestly didn't know that I can't print regions in node templates - I should've checked this out way earlier.

I added the print region into page-node.tpl.php, but because I only want it on "story" pages, I added this PHP-visibility setting for the block:

<?php
$match
= FALSE;
$types = array('story' => 1);
if (
arg(0) == 'node' && is_numeric(arg(1))) {
 
$nid = arg(1);
 
$node = node_load(array('nid' => $nid));
 
$type = $node->type;
  if (isset(
$types[$type])) {
   
$match = TRUE;
  }
}
return
$match;
?>

which I got from the block modules handbook.

I've learnt a bit more about Drupal today. Thanks a lot :)
Will close issue.

#5

bluepen - July 7, 2009 - 15:13
Status:active» fixed

Actually, I managed to google some tutorials on how to print regions/blocks in nodes. Productive day!

Thanks.

#6

jchatard - July 7, 2009 - 15:14

You're welcome!

Jérémy

#7

System Message - July 21, 2009 - 15:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.