0

I have a search view, and I use the exposed form as a block to put the search box on every page. In the block configuration I hide the exposed form block title so that I'll just get the search form with no title.

That works fine, but now on the Admin dashboard, I want to include the same search box. The dashboard shows the block title, which is what I want, except the view title is 'Exposed form: publication_search-page' which is gross.

If I try to go into the block configuration and change the block title to Publication Search, I override the that is in there now, and the title starts showing up everywhere.

How can I change the block title in the dashboard (or when I'm using the adminimal theme or whatever the admin theme is set to if that is easier) without messing up the configuration to hide it on all the other pages?

2
  • Have you set the title within the views view display for the block? Commented Sep 13, 2016 at 8:31
  • I'm not entirely sure that I know what you mean, but since I didn't bother setting a display name, it is set to page. I want the block title to end up being Publication Search.
    – UltraBob
    Commented Sep 13, 2016 at 23:49

1 Answer 1

1

Here is a per theme solution.

In your View, under Advanced, click on Theme Information, the following pops up:

enter image description here

Now click on style output, and copy the entire code inside in to a new file in your text/code editor.

In my case it is:

<?php

/**
 * @file
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>
  </div>
<?php endforeach; ?>

Change the <h3><?php print $title; ?></h3> to <h3>Your Custom Title</h3>

Then save the file as views-view-unformated--[view-name]--[machine-name].tpl.php

(In my screenshot, example is the name of my view, and machine name is page, basically use last name suggestion)

enter image description here

Put this template file in your Adminimal theme's template folder and clear the cache to see changes.

7
  • Thanks, that is great, I'll try to see if I can modify that to remove the title from my non admin theme while allowing me to configure it elsewhere.
    – UltraBob
    Commented Sep 13, 2016 at 8:50
  • It wasn't working for me so I turned on theme debug, and see that the template names are different for exposed forms. I'm getting block--views---exp-publication-search-page.tpl.php. Now I need to go find that default exposed form template.
    – UltraBob
    Commented Sep 13, 2016 at 9:13
  • @UltraBob Click on Theme Information link in views.
    – No Sssweat
    Commented Sep 13, 2016 at 9:25
  • Yeah, I did that. It doesn't give me any information on exposed form views.
    – UltraBob
    Commented Sep 13, 2016 at 9:31
  • So I've tried copying views-exposed-form.tpl.php from views to block--views---exp-publication-search-page.tpl.php in my theme, but even when I don't change anything I get warnings that $widgets is undefined, so I seem to be on the wrong track there. Following the guidance in the answer had no impact on how the exposed form block appeared. My first thought was to do a preprocess_block theme function, but I didn't have much success with that at first, maybe I should try at that some more.
    – UltraBob
    Commented Sep 13, 2016 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.