Closed (duplicate)
Project:
Block Class
Version:
6.x-1.x-dev
Component:
Documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
28 Nov 2008 at 09:46 UTC
Updated:
6 Dec 2018 at 12:39 UTC
Jump to comment: Most recent
Comments
Comment #1
todd nienkerk commentedprovinciadicuneo: The Block Class module can indeed be used to provide an ID instead of a class. However, it's preferable from a theming standards standpoint to stick to the ID already provided by block.tpl.php. See the first line:
This will create an ID pattern of
block-MODULE_NAME-DELTA_VALUE. For example, user-generated blocks (i.e., custom blocks created in the Admin > Site Building > Blocks interface) use the ID patternblock-block-2, where "2" is the delta value (unique identifier) for that block.You can use the ID pattern described above to style your block with CSS.
Also, I should note that the technique you describe may cause problems in the long run. If more than one block is assigned the same ID, you run the risk of having two elements with the same ID appear simultaneously on a page. This will result in invalid markup and may cause problems in some browsers.
Comment #2
todd nienkerk commentedComment #3
klonosThanx for sharing this info. I'd like to add these three links here:
Create block id attributes based on block title
Give your Drupal blocks a more descriptive HTML ID attribute
Core Block CSS IDs (...shows how core block IDs have changed in D7 compared to the ones in D6)
I would like to kindly suggest this to become a feature of this module, but I'm not changing this issue's category from 'task' though. Thanx in advance for considering.
PS: ...perhaps my request belongs to a separate, new module. A 'Custom block IDs' perhaps? ;)
Comment #4
klonos@Todd:
...unless there's an extra check to see if there's an ID with the same value in the document of course. In that case the
$block->deltacould be concatenated to the new id to avoid duplicate IDs. In D7 this could be done by checking the entered ID value against the core blocks' IDs + against all enabled contrib blocks' IDs before saving the new block ID.Comment #5
todd nienkerk commented@klonos: This issue is a duplicate of #863554: Add ability to set a block's CSS ID.
Comment #6
Anonymous (not verified) commentedthis module may be helpful, by using this module you may add separate block id.
https://www.drupal.org/project/block_id