How to make different slogan for each content type?

I have several content types, I want the slogan that shows up on the page to be different for each slogan. Is this possible?

Replay

You can use a preprocess function:

function mymodule_preprocess_page(&$variables) {
  if (isset($variables['node'])){
    switch ($variables['node']->type) {
      case 'my_content_type2':
        $slogan = "my super slogan 1";
        break;
      case 'my_content_type2':
        $slogan = "my super slogan 2";
        break;
      default:
        $slogan = "my super slogan 3";
    }
    $variables['site_slogan'] = $slogan;
  }
}

In this case, you preprocess the page before it is sended to the template engine. More exactly, you change the 'site_slogan' variable according to the node type.

You can add this function in a module: in this case replace "mymodule" in the function's name by the name of your module

or you can add this function in the "template.php" file of your theme folder: in this case replace "mymodule" in the function's name by the name of your theme.

Category: 7 Time: 2016-07-29 Views: 4

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.136 (s). 13 q(s)