How can I change the view block ID from block-views-portfolio-view-block to portfolio?
-
Why do you want to? If it is for theming, you can append a class to any block using drupal.org/project/block_class– Neograph734Jun 7, 2016 at 14:15
-
No, it's for creating "all in one page" portfolio. Now I have #contact, #about etc., ad #block-views-portfolio-view-block in addition to this doesn't look too good ;) and it is displayed in addres bar– rukyaJun 8, 2016 at 5:28
2 Answers
Add this to your theme's template.php file:
function THEME_preprocess_block(&$variables) {
if ($variables['block_html_id'] == "block-views-portfolio-view-block")
$variables['block_html_id'] = "portfolio";
}
An alternative without coding would be to use Token Embed Views, to embed the view in a custom block. You can use something like Block attributes (Drupal 7) to set an id to that block.
Or you could override the Views display output. If you go the the right bottom of the views interface, click Information
next to theme you'll see a list of names. You could wrap the contents of the used template (probably views-view.tpl.php
) into another div with your id, and save the file in your theme folder. Use the most accurate filename suggested that still applies to all pages (some with built in node id's etc.).