I am looking for a module that can create sitemap in Drupal, but couldn't find any. I tried Site Map module, but it can only generate a sitemap page; it can't create a sitemap block at the end of every page. I also tried site menu module, but it can't create a sitemap block as shown above, as well.
Maybe it's just that I don't know how to configure, but I read every readme file, and tried for a few days, still can't get it to work.
Anyone has any idea?
I had the same problem, after trying a module (site-map) but missing customization options I wrote a custom module. Took less time then messing with the site-map module, for just getting a site map the following code is enough (adapt your-menu):
function sitemap_render_menu ($menu) {
$output = "<ul>";
foreach ($menu as $item) {
$link = $item["link"];
if ($link["hidden"]) {
continue;
}
$output .= "<li>" . $link["title"] . "</li>";
if ($item["below"]) {
$output .= sitemap_render_menu($item["below"]);
}
}
$output .= "</ul>";
return $output;
}
function sitemap_content () {
$output = "<h1>Sitemap</h1>";
$output .= "<span id=\"sitemap\">";
$output .= sitemap_render_menu(menu_tree_all_data("your-menu"));
$output .= "</span>";
return $output;
}
function sitemap_menu () {
$items = array();
$items["sitemap"] = array (
"title" => "Sitemap",
"page callback" => "sitemap_content",
"access arguments" => array("access content"),
"type" => MENU_CALLBACK);
return $items;
}
There is a basic comparison of sitemap modules at http://groups.drupal.org/node/15980
I have used sitemenu and it worked for my needs, but the real answer depends on how you structure your site with taxonomy, content types, etc.
Something like Auto Menu might work for you here as well. You could simply add the menu it generates to a footer block on your front page.
With the Site Map module installed, this php code will print the site map.
<?php echo theme('site_map'); ?>
You could create an empty views block and specify the above for the empty text, selecting the PHP Code input format.
There may be a better way to create a custom block to display php code, but I don't know it.
My idea here is to use Views module with customized block type.
I think you can benefit from Menu block module. as you can create menu blocks for all the menus you need in the footer. Then you can add them all in footer or in a one block using minipanels block (from panels module).
You can use Footer_sitemap module which provides us with the configurable block.
https://drupal.org/project/footer_sitemap
This is a little mod of best answer it uses current theme to show hierarchy
function sitemap_render_menu ($menu) {
$output = "<ul class='menu'>";
foreach ($menu as $item) {
$link = $item["link"];
if ($link["hidden"]) {
continue;
}
$cc=($item["below"]) ? "class='collapsed'" : '';
$output .= "<li $cc>" . $link["title"] . "";
if ($item["below"]) {
$output .= sitemap_render_menu($item["below"]);
}
$output .= "</li>";
}
$output .= "</ul>";
return $output;
}
function sitemap_content ($title,$menu) {
$output = "<h1>$title</h1>";
$output .= "<span id=\"sitemap\">";
$output .= sitemap_render_menu(menu_tree_all_data($menu));
$output .= "</span>";
return $output;
}
function sitemap_menu () {
$items = array();
$items["sitemap"] = array (
"title" => "Sitemap",
"page callback" => "sitemap_content",
"access arguments" => array("access content"),
"type" => MENU_CALLBACK);
return $items;
}
print sitemap_content("Navigational menu","Navigation");
A simple solution which doesn't depend on content being included as a menu item can be achieved by :
Creating a new view
Output as a block
Using Fields:
Content Title (configured to "Link this field to the original piece of content"
Content Type (configured to "Exclude from display")
Format as
Unformatted list with settings - Grouping field Nr.1 select Content:Type;
Filter Criterea:
Content: Published (Yes)
Content Type - Configure to select the content types you wish to include;
Sort criteria - Configure as per your preference
Related
I have Install WordPress and i need all tags should be display in drop down like category
Also I want search filter over there
when i want to put any comma separate tag in search box all tag should be checked in drop down automatically
You can use this function to get all the tags in the WP.
$tags = get_tags(array('get'=>'all'));
example,
$tags = get_tags(array('get'=>'all'));
$output .= '<ul class="tag-cloud-list">';
if($tags) {
foreach ($tags as $tag):
$output .= '<li>'. $tag->name .'</li>';
endforeach;
} else {
_e('No tags created.', 'text-domain');
}
$output .= '</ul>';
return $output;
The same way you can use the checkbox in the place of UL and LI. Also, you can use the add_meta_box() to add the tags to the all post type.
For more details, Please visit.
https://developer.wordpress.org/reference/functions/add_meta_box/
https://developer.wordpress.org/reference/functions/get_tags/
The Devel module query log appears correctly (at the bottom of the page) when I use one of the default themes, but not when I switch to my custom theme. The query log seems to appear within the inner pages in the custom theme, though not the front page or administrator pages (if those are set to use the custom theme).
I have been through page.tpl.php and html.tpl.php and I can't see any missing variables.
How does the query log get printed on the page?
STEP 1:
Check in your template.php you can find the next hooks. If it doesnt exists, create it.
function YOURTHEME_preprocess_node(&$variables) {
$variables['messages'] = theme('status_messages');
}
function YOUTRHEME_status_messages($variables) {
$m = drupal_get_messages();
foreach ($m as $type => $messages) {
if (count($messages) > 0) {
$output .= "<div class=\"messages\">";
$output .= " <ul>";
foreach ($messages as $key => $message) {
if (count($messages) > 0) {
$output .= '<li class="message '.$type.'"><span class="text">'. $message . "</span></li>";
}
}
$output .= " </ul>";
$output .= "</div>";
}
}
return $output;
}
STEP 2
In your template check if var $message is printed. If it doesnt exists, create it.
print $message;
Having fought with the problem of showing child terms for a given taxonomy term in a block, I finally stumbled on a piece of code that does exactly what I want here
As per the instructions I've added the following to my template.php
function themename_child_terms($vid = 1) {
if(arg(0) == 'taxonomy' && arg(1) == 'term') {
$children = taxonomy_get_children(arg(2), $vid);
if(!$children) {
$custom_parent = taxonomy_get_parents(arg(2));
$parent_tree = array();
foreach ($custom_parent as $custom_child => $key) {
$parent_tree = taxonomy_get_tree($vid, $key->tid);
}
$children = $parent_tree;
}
$output = '<ul>';
foreach ($children as $term) {
$output .= '<li>';
$output .= l($term->name, 'taxonomy/term/' . $term->tid);
$output .= '</li>';
}
$output .= '</ul>';
return $output;
}
}
I've then created a block and added :
<?php // $vid is the vocabulary id.
print themename_child_terms($vid = 1);
?>
This shows the child terms of the current term perfectly. However, it shows ALL terms that exist under the parent term, even if there is no piece of content using that term.
e.g.
viewing the page with all items in Term 1, I get
child 1
child 2
child 3
correctly listed in the block. But, if there are no pieces of content tagged with 'child 3' for example, it's still showing up that term in the block. This isn't very useful as it links to an empty term page.
How would I modify the code to only show children that actually have items associated with them. So if there are no children tagged 'Child 3', then that term would not show up. Is it an easy modification?
Thank you kindly for any solutions.
Nick
Working with Drupal 6
Thanks to user jerdiggity for posting the following reply over on drupal.stackexchange here. Works perfectly.
Hmm... I'd try something like this:
Change this part of your code:
foreach ($children as $term) {
$output .= '<li>';
$output .= l($term->name, 'taxonomy/term/' . $term->tid);
$output .= '</li>';
}
to something like this:
// Avoid unnecessary "Invalid foreach" errors showing up in the log:
if (!empty($children)) {
// If not empty, run the foreach loop:
foreach ($children as $term) {
// Then check to see if any nodes exist for that term id:
$number_of_nodes = taxonomy_term_count_nodes($term->tid);
// If there ARE nodes...
if ($number_of_nodes > 0) {
// ... then add them to the output:
$output .= '<li>';
$output .= l($term->name, 'taxonomy/term/' . $term->tid);
$output .= '</li>';
}
}
}
Hope that helps... :)
I have a custom module that generates a page of output, my question is about how to add html elements to the output such as headings and paragraphs etc.
My module is as follows
function mymodule_page() {
$output .= '<h3>'.t('Installs '.$cell).'</h3>';
$output .= theme('flot_graph', $graph1);
return $output;
}
is this the correct way to do this?
should line two be like this instead?
$output .= t('<h3>Installs '.$cell.'</h3>');
I prefer do not mix logic and presentation in module files, so I would use a tpl to print the content. For example, in your module I would put this code:
function mymodule_page() {
return theme_render_template(drupal_get_path('theme', 'your_theme') . 'path/to/your/file.tpl', array('cell' => $cell, 'graph1' => $graph1);
}
And in the tpl file:
<h3><?php echo t('Installs') . ' ' . $cell; ?></h3>
theme('flot_graph', $graph1);
I am using Taxonomy_Manager and Menu_breadcrumb modules
my categories looks like:
+BUSINESS
++Agriculture
++Banking & Finance
++Construction & Real Estate
+News
++ Behind the news
++ Peace and War
now the question is: if i browse any sub-category, it will not appear in the breadcrumb
(the breadcrumb will be "Home>>") while if i browse one of the main categories, it will appear normally in the breadcrumb ("Home>>News")
i have tried taxonomy_breadcrumb but this didnt fix the issue :(
how can i set the subcategories to appear in the breadcrumb??
Thanks for your help
Use any of these modules:
http://drupal.org/project/hansel
http://drupal.org/project/custom_breadcrumbs
I solved all my breadcrumb-taxonomy related problems overriding the druapal breadcrumb function. You have to go to your theme folder and add the follow function in your template.php file.
function YOUR_THEME_NAME_breadcrumb( $variables )
{
// init
$breadcrumb = $variables['breadcrumb'];
// taxonomy hierarchy
$hierarchy = array();
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)))
{
$tid = (int)arg(2);
$parents = array_reverse(taxonomy_get_parents_all($tid));
foreach( $parents as $k=>$v)
{
if( $v->tid==$tid ) continue;
$breadcrumb[] = l($v->name, 'taxonomy/term/'. $v->tid);;
}
}
// rendering
if (!empty($breadcrumb))
{
$output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
$output .= '<div class="breadcrumb">' . implode("<span class='separator'>ยป</span>", $breadcrumb) . '</div>';
return $output;
}
}