December 2010

Sprog - flere sprog på Drupal

Nedenstående indsættes i settings.php for at kunne benytte flere forsider (en for hvert sprog). Også mulighed for side navn, slogan etc. (her er disse muligheder dog udkommenteret med // - læs mere her: http://drupal.org/node/313272

Kode (XHTML, PHP, CSS etc.): 
/** * Multilingual settings * * This is a collection of variables that can be set up for each language when i18n is enabled. * These are the basic ones for Drupal core, but you can add your own here. */ $conf['i18n_variables'] = array( // Site name, slogan, mission, etc.. // 'site_name', // 'site_slogan', // 'site_mission', // 'site_footer', // 'anonymous', // Different front page for each language 'site_frontpage', // Primary and secondary links // 'menu_primary_links_source', // 'menu_secondary_links_source', // Contact form information // 'contact_form_information', );

PHP

Vis information omkring et array
<php print_r ($img); ?>

Print eksempelvis idescription på et billede fra array "img" i page.tpl.php
<?php print $img['data']['description'];?>

WC3 validering: 
PHP
Kode (XHTML, PHP, CSS etc.): 

<php print_r ($img); ?>
<?php print $img['data']['description'];?>

Vis block på bestemt contenttype og URL

Vises her på contenttype = blog og URL = /blog og URL = forside

Nederst kun på content type!

WC3 validering: 
PHP
Kode (XHTML, PHP, CSS etc.): 
<?php
  $match
= FALSE;
 
$types = array('blog' => 1);
 
$uris = array('/blog' => 1, '/forside' => 1);

  if ((
arg(0) == 'node') && is_numeric(arg(1))) {
   
$node = node_load(arg(1));
   
$match = isset($types[$node->type]);
  }

 
$match |= isset($uris[request_uri()]);

  return
$match;
?>
<?php
// Change the type to the one you want to match on
$desired_type = 'story';
if (
arg(0) == 'node' && is_numeric(arg(1)) ) {
 
$node = node_load(arg(1));
   return
$node->type == $desired_type;
}

return
FALSE;
?>