Hello,
Is there a nice way to theme the output of the site map. I would like to be able to override the function that is spitting out the HTML.

Maybe a nice feature to have a themeable function.
I could write some nice CSS..

What you think?

chris

CommentFileSizeAuthor
#5 site_map_theme.patch4.24 KBfrjo

Comments

f_p’s picture

Hi Chris,

In order to ease theming site maps using CSS, I've modified function _site_map_menus in site_map.module as follows:

        $output .= "<div class='sitemap-menu' id='menu-$mid'>"
          . theme('box', $title, $menu_display)
          . "</div>";

instead of just $output .= theme('box', $title, $menu_display);.

This surely can be generalized throughout the module.

Cheers,
Franck

cbovard’s picture

thank you

bartezz’s picture

Thanx for making the output themable!

But how can I use this? Do I make a tpl.php, and what should I call it?
Or do I have to write a function in my template.php?

Sorry for possibly a dumb question, but I can't find any documentation on theming this module.

Cheers

bartezz’s picture

Hi,

I tried the following;

/**
 * Theme the sitemap output.
 */
function themename_box($title, $output) {
	return $output;
}

And it has effect, yet it only will allow you to target the title or the pre-formatted list of sitemap items. Not the items itself.
This will do for me now though. But if someone has more info on this matter and cares to share, please do :)

Cheers

frjo’s picture

StatusFileSize
new4.24 KB

cbovard solution gives you css classes like "sitemap-menu" that you can make use of in your themes css files.

I expanded on cbovard idea and added a lot of classes to the site map as well as give site map it own theme_site_map_box() function.

Please try it out and tell me what you think. If you like it I will add it to 6-dev.

frjo’s picture

Assigned: Unassigned » frjo
Status: Active » Fixed

I have committed patch #5 to 6-dev.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

eff_shaped’s picture

bookmarking

Want to hide title (h2's) and the home page link from site map list. This thread is all I've found to help me so far.

Anyone know of further documentation...?

frjo’s picture

Version: 5.x-1.2 » 6.x-1.x-dev

Take a look at theme_site_map_display() and theme_site_map_box(). Make your own versions of them in your theme and you can get the output you like.

Overriding themable output https://drupal.org/node/341628

eff_shaped’s picture

That gives me hope, frjo. I have a few questions...

Where would I find theme_site_map_display() and theme_site_map_box()?

Are they functions?

Do I copy them into my theme.php file?

Can you give me some insight into what php would make the h2's and links not display?

thanks

eff_shaped’s picture

Answering my own questions, after some trial and error... for the benefit of beginner themers, like myself.

I found the functions theme_site_map_display() and theme_site_map_box() in the site_map.module file (in the sitemap module folder).

Copied them into the template.php for my theme (at the bottom of the code).

Changed 'theme_' to 'mythemename_' in both cases.

REMOVING HEADINGS FROM SITEMAP
The H2 headings I wanted to hide are output by the 'theme_site_map_box()' function:

function theme_site_map_box($title, $content, $class = '') {
  return  '<div class="sitemap-box '. $class .'"><h2 class="title">'. $title .'</h2><div class="content">'. $content .'</div></div>';
}

I deleted the section: <h2 class="title">'. $title .'</h2>
This gives me a sitemap with listings of the links only. Without titles like 'Primary Links' etc.
This will work for you if you don't want ANY titles over your site links on this page.

SITE MAP MESSAGE IN A DIFFERENT PLACE
In my theme (adapted from pixture_reloaded), the default message for Sitemap appears above the breadcrumbs; I want it below the Site Map heading.

Using the 'theme_site_map_display()' function, I inserted a hard coded message that will display where I want it. I leave the message blank in site map settings page.

Here's what the code looks like:

function theme_site_map_display() {
  $output = '';

  if ((variable_get('site_map_show_rss_links', 1) != 0).......... and so on...................

  ..................... until ..........................
/*   $output .= _site_map_video(); */

.................... at which point I entered the line................

     $output .= '<p>'.t('THE MESSAGE').'</p>'; 

This displays the string 'THE MESSAGE' on my page where I want it. (Below the heading and above the content.)
This paragraph can be changed to anything by editing this line of the template.php file.

I'll post again, if I ever find a way to hide particular links on this page (eg. 'Home' and 'Site Map' are redundant links in my case).

tigron’s picture

Version: 6.x-1.x-dev » 6.x-2.1

I'm trying to use the information provided by eff_shaped but I'm not finding functions theme_site_map_display() and theme_site_map_box() in the site_map.module file. Is this something that changed since the last version ? I just want to remove the primary links title from the top of the site map page.