I find adding an encoded node->title to the html classes is needed for CSS designers. Using the node->nid is not good and can have issues if you use node export/import that can change node ordering.
Adding this small piece of code I now render content as blocks with good class CSS like I had using my old workaround with views.
The views module renders the view's->title with block as the prefix and postfix.
I used the same name style so I have the added benefit of reusing the same CSS that was previously used while using the views hack to display content nodes as blocks.
Here is my somewhat sloppy fix in: node-nodeblock-default.tpl.php
...
if( $node->title ) {
$classes .= ' block-' . strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $node->title)) . '-block';
}
?>
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
...
It does the trick.. But I'm sure you know a better solution.
Please patch soon :)
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | [description]-[issue-number]-[comment-number].patch | 6.05 KB | steverweber |
Comments
Comment #1
steverweber commentedI don't care much for the -block postfix. kinda looks sloppy to me.. drop it if you want.
Comment #2
Johnny vd Laar commentedNode titles are even more subject to change. I think you should use a module like block class to accomplish this. http://drupal.org/project/block_class
In the near future I'm planning a machine name field on the node block node.
Comment #3
steverweber commentedI have created a machine name field patch.
So now the settings can be saved in features without issues of id offsets.
The patch is not backwards compatible... However I feel its a good direction.
I'll post it sometime tomorrow after some extra testing.
Thanks..
Comment #4
steverweber commentedI attached the patch... Note I still have some debug output chilling in there...
It needs some work however for the most part it works.
The issues...
- I'm not sure how to handle nodeblock_translation_fallback_
- using the node title as the machine name could clead to overlap... might be nice to make this value a field for user to custom
Comment #5
Johnny vd Laar commentedThanks for the patch. I'm currently not able to look at it but I'll look into it whenever I have time.
Comment #6
Johnny vd Laar commentedI have added a machine name field.
It's added here:
http://drupalcode.org/project/nodeblock.git/commitdiff/23ab1cb?hp=9fd890...
Please reopen this one if you find a bug in this.
Comment #7
steverweber commentedComment #8
steverweber commentedComment #9
steverweber commentedI'm exporting my nodes with block info using features.fe_block_settings...
When importing settings for content and blocks I hit this Notice.
Notice: Undefined index: custom_machine_name in nodeblock_node_insert() (line ~291 of nodeblock/nodeblock.module).
line:
my $values are:
I use something like this to work around that issue.?
Another issue:
When creating new nodes that don't have nodeblock... I get this notice and error:
my workaround is to ignore nodes that dont pass nodeblock_type_enabled
I then hit more issues when creating new nodes with that have nodeblock enabled but node->nodeblock is not set...
Some of the issues might be caused my my profile... Perhaps my testing was a little helpful.
Thanks.
Comment #10
Johnny vd Laar commentedI've added a fix with this commit:
http://drupalcode.org/project/nodeblock.git/commit/43d6985
Let me hear if the problem persists please.
Comment #11
steverweber commentedExcellent turnaround.
I'll give it another round of testing.