Tutti i modi per scrivere la funzione l() e la funzione t() di drupal 6
Ecco un elenco abbastanza completo su come scrivere la funzione l(). Chi ha dimestichezza con php e ha presente la api di Drupal può trarne spunto per sviluppare del codice personalizzato.
l($text, $path, $options = array())
<?php
$output .= '<a href="'. check_url($item->link) .'">'. check_plain($item->title) ."</a>\n";
$output .= '<li><a href="'.$base_path.'/taxonomy/term/'.urlencode($data->tid).'">'.$data->name.'</a></li>';
l(
t('My link'),
'node/56',
array(
'attributes' => array(
'class' => 'widelink',
'rel' => 'lightbox',
)
)
);
l(t('Title'),$url, array('attributes' => array('target' => '_blank')));
l(t('Link text'), 'about-us', array('attributes' => array('class' => 'about-link')));
l(t($user->name), 'user/'.$user->uid, array('attributes' => array('class' => 'link', 'id' => 'xxx', 'title' => 'Title')));
$link = l(t($title), $path, array('language' => 'pl'));
l(t('Title'), $url, array('attributes' => array('onclick' => 'window.open(this.href); return false;')));
//To create a link to a named anchor (e.g. #namedanchor ) you will need to use a small work-around.
l('linktext', '', array('fragment' => 'namedanchor', 'external' => TRUE));
//To create a hash-only link (to #) you'll need to adapt it to:
l('linktext', '', array('fragment' => ' ', 'external' => TRUE));
//To clarify for those who want their module to support the 'Clean URLs' option.
$var = l("Click Text", "ModuleName"); returns a link complete with <a href= tags.
//For a link that goes with your hook_menu() and 'page arguments' you just add the arguments to the path.
$var = l("Click Text", "ModuleName/value/value");
//If you need a link without the <a href= tags use 'url' instead.
$var = url("ModuleName/value/value");
$img = '<img src="'.$base_path . $directory . '/images/rssIcon.png" />';
l($img, 'user/3', array('html' => 'true'));
l($img, 'user/3', array('attributes' => array('class' => 'link', 'id' => 'xxx', 'title' => 'Title'), 'html' => 'true'));
$options = array( "attributes" => array("title" => t("Here you can modified your data private") ) );
$link1 = l( t('Edit your data'), 'candidati/editdata', $options);
$page_content = "<div class="tabs"><ul class="tabs primary"><li>" . $link1 . "</li><li class="active" ></li></ul></div>";
$options = array( "attributes" => array("title" => t("From here you can enter the necessary information (CV, photos, video)") ) );
$link1 = l( t('Insert data'), 'candidati/main', $options);
$block_content .= "<div class="more-link">" . $link1 . "</div>";
$links = array();
foreach ($languages[1] as $language) {
$links[$language->language] = array(
'href' => $path,
'title' => $language->native,
'language' => $language,
'attributes' => array('class' => 'language-link'),
);
}
$query = "SELECT tid, name from {term_data} WHERE description = '' ORDER BY name ASC";
$result = db_query($query);
while ($term = db_fetch_object($result)) {
$items[]= l($term->name, "taxonomy/term/$term->tid");
}
if(count($items)) {
return theme('item_list',$items);
}
?>
Ecco un elenco abbastanza completo su come scrivere la funzione t().
t($string, $args = array(), $langcode = NULL)
<?php
$message = t('The content access permissions need to be rebuilt.');
$ranking = array('node_rank_relevance' => t('Keyword relevance'), 'node_rank_recent' => t('Recently posted'));
$header = array(t('Factor'), t('Weight'));
$item_text = '<p>'. l(t('read more'), 'node/'. $item->nid, array('absolute' => TRUE, 'attributes' => array('target' => '_blank'))) .'</p>';
$default_message .= '<li>'. t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/settings'))) .'</li>';
$form['#prefix'] .= '<em>'. t('This is the top-level page in this book.') .'</em>';
$read_more = theme('more_link', url('aggregator/sources/'. $feed->fid), t("View this feed's recent news."));
return '<div class="log"><div class="title">'. t('Log') .':</div>'. $log .'</div>';
return '<p>'. t('The revisions let you track differences between multiple versions of a post.') .'</p>';
form_set_error('name', t('The username %name does not exist.', array('%name' => $node->name)));
form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->min_word_count, '@type' => $type->name)));
drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))));
drupal_set_message(t('@type %title has been deleted.', array('@type' =>
node_get_types('name', $node), '%title' => $node->title)));
?>
Argomenti:
- Accedi o registrati per inserire commenti.