本文整理汇总了PHP中arg函数的典型用法代码示例。如果您正苦于以下问题:PHP arg函数的具体用法?PHP arg怎么用?PHP arg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: goodboymytheme_preprocess_page
/**
* Preprocessor for page.tpl.php template file.
*/
function goodboymytheme_preprocess_page(&$vars, $hook)
{
//----------------------------------------------------Goodboy my custom Stage 4 p.5
if (arg(0) == 'node') {
if ($vars['node']->type == 'film') {
$vars['title'] = 'Films Films Films';
}
}
// For easy printing of variables.
$vars['logo_img'] = '';
if (!empty($vars['logo'])) {
$vars['logo_img'] = theme('image', array('path' => $vars['logo'], 'alt' => t('Home'), 'title' => t('Home')));
}
$vars['linked_logo_img'] = '';
if (!empty($vars['logo_img'])) {
$vars['linked_logo_img'] = l($vars['logo_img'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home')), 'html' => TRUE));
}
$vars['linked_site_name'] = '';
if (!empty($vars['site_name'])) {
$vars['linked_site_name'] = l($vars['site_name'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home'))));
}
// Site navigation links.
$vars['main_menu_links'] = '';
if (isset($vars['main_menu'])) {
$vars['main_menu_links'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('id' => 'main-menu', 'class' => array('inline', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
}
$vars['secondary_menu_links'] = '';
if (isset($vars['secondary_menu'])) {
$vars['secondary_menu_links'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('id' => 'secondary-menu', 'class' => array('inline', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
}
}
示例2: songlap_preprocess_page
/**
* @file
* This file is empty by default because the base theme chain (Alpha & Omega) provides
* all the basic functionality. However, in case you wish to customize the output that Drupal
* generates through Alpha & Omega this file is a good place to do so.
*
* Alpha comes with a neat solution for keeping this file as clean as possible while the code
* for your subtheme grows. Please read the README.txt in the /preprocess and /process subfolders
* for more information on this topic.
*/
function songlap_preprocess_page(&$vars)
{
if (drupal_is_front_page()) {
$breadcrumb = array();
$breadcrumb[] = t('Home');
drupal_set_breadcrumb($breadcrumb);
}
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_null(arg(3))) {
$term = taxonomy_term_load(arg(2));
$breadcrumb = '';
$breadcrumb .= '<div class="breadcrumb">';
$breadcrumb .= '<a href="' . $vars['front_page'] . '">' . t('Home') . '</a> ';
$breadcrumb .= '» ' . $term->name;
$breadcrumb .= '</div>';
$vars['breadcrumb'] = $breadcrumb;
}
if ($_GET['q'] == 'projects') {
$breadcrumb = '';
$breadcrumb .= '<div class="breadcrumb">';
$breadcrumb .= '<a href="' . $vars['front_page'] . '">' . t('Home') . '</a> ';
$breadcrumb .= '» ' . t('Projects');
$breadcrumb .= '</div>';
$vars['breadcrumb'] = $breadcrumb;
}
}
示例3: lt_preprocess_views_view
function lt_preprocess_views_view(&$vars)
{
if ($vars['view']->name == 'articles' && arg(0) == 'taxonomy') {
$term = taxonomy_term_load(arg(2));
$vars['header'] = '<h2 class="block-title">' . $term->name . '</h2>';
}
}
示例4: fs_core_preprocess_page
/**
* Implemements hook_process_page
* @param array $variables
*/
function fs_core_preprocess_page(&$variables)
{
//Search form
$search_form = drupal_get_form('search_form');
$search_form_box = drupal_render($search_form);
$variables['search_box'] = $search_form_box;
if ($views_page = views_get_page_view()) {
$variables['theme_hook_suggestions'][] = 'page__views__' . $views_page->name;
$variables['theme_hook_suggestions'][] = 'page__views__' . $views_page->name . '_' . $views_page->current_display;
}
if (isset($variables['node']->type)) {
$variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
}
// changes the links tree for the main menu, since by
// default Drupal just provides first level ones
$menu_tree = menu_tree_all_data('main-menu');
$menu_tree = menu_tree_output($menu_tree);
foreach ($menu_tree as $k => $v) {
if (is_numeric($k) && count($v['#below'])) {
$menu_tree[$k]['#below']['#theme_wrappers'][0] = 'menu_tree__submenu';
}
}
$variables['main_menu'] = $menu_tree;
if (arg(0) == 'taxonomy' && arg(1) == 'term') {
$tid = (int) arg(2);
$term = taxonomy_term_load($tid);
if (is_object($term)) {
$variables['theme_hook_suggestions'][] = 'page__taxonomy__' . $term->vocabulary_machine_name;
}
}
}
示例5: freelinking_prepopulate_fields_from_page
/**
* Extract the specified array fields from the current or specified page.
* Build a l() 'query' array suitable for use by Prepopulate.
*
* @param $fields
* Array of fields to process.
* @param path
* If NULL, the current page. Otherwise, lookup the path and use that page.
* (Path lookup not yet implemented)
*
* @see freelinking_prepopulate_list_fields(), l()
*/
function freelinking_prepopulate_fields_from_page($fields, $plugin = 'nodecreate', $path = NULL)
{
static $prepopulate;
$query = array();
$index = $plugin . serialize($fields);
if (!$prepopulate[$index]) {
$prepopulate[$index] = array_intersect_key(freelinking_prepopulate_list_fields($plugin), $fields);
}
if ($plugin == 'nodecreate' && arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
$object = node_load(arg(1));
}
foreach ($prepopulate[$index] as $field => $definition) {
switch ($field) {
case 'og':
$group = og_get_group_context();
$query[$definition['prepopulate']] = $group->nid;
break;
case 'book':
if ($node->book) {
$query['parent'] = $object->book['mlid'];
}
break;
default:
if ($object->{$field}) {
$query[$definition['prepopulate']] = $object->field;
}
break;
}
}
return $query;
}
示例6: equinox_preprocess_page
/**
* @file template.php
* This file provides theme functions to override or extend Drupal behavior.
*
* @author Raymond Jelierse
*/
function equinox_preprocess_page(&$variables) {
// Default JavaScript settings
$theme_settings = array(
'carouselTimeout' => 10000,
'carouselTransitionSpeed' => 500,
);
// Refresh theme settings
theme_get_setting('', TRUE);
if (theme_get_setting('carousel_timeout') !== NULL) {
$theme_settings['carouselTimeout'] = intval(theme_get_setting('carousel_timeout'));
}
if (theme_get_setting('carousel_transition_speed') !== NULL) {
$theme_settings['carouselTransitionSpeed'] = intval(theme_get_setting('carousel_transition_speed'));
}
drupal_add_js(array('equinox' => $theme_settings), 'setting');
$variables['scripts'] = drupal_get_js();
// Create user menu
$variables['user_menu'] = theme('links', menu_navigation_links('navigation'), array('id' => 'user-links-menu', 'class' => 'links user-links'));
// Add check variable for administration section.
$variables['is_admin'] = (arg(0) == 'admin');
// Remove breadcrumb if not in the administration section.
if (!$variables['is_admin']) {
$variables['breadcrumb'] = '';
}
// Multilanguage site logo
$variables['logo'] = sprintf('%s/images/logo-%s.png', url(drupal_get_path('theme', 'equinox')), $variables['language']->language);
}
示例7: stability_process_page
/**
* Implementation of hook_preprocess_page().
*/
function stability_process_page(&$variables)
{
global $user;
$variables['login_account_links'] = '';
if (theme_get_setting('login_account_links') || module_exists('uc_cart')) {
$output = '';
if (theme_get_setting('login_account_links')) {
$output .= '<span class="login">
<i class="fa fa-lock"></i> ' . l($user->uid ? t('My Account') : t('Login'), 'user') . '
</span>';
$output .= $user->uid ? '<span class="logout"><i class="fa fa-sign-out"></i> ' . l(t('Logout'), 'user/logout') . '</span>' : '';
$output .= !$user->uid ? '<span class="register"><i class="fa fa-pencil-square-o"></i>' . t('Not a Member?') . ' ' . l(t('Register'), 'user/register') . '</span>' : '';
}
if (module_exists('uc_cart')) {
$output .= '<span class="cart">
<i class="fa fa-shopping-cart"></i> ' . l(t('Shopping Cart'), 'cart') . '
</span>';
}
$variables['login_account_links'] = '
<div class="header-top-right">
' . $output . '
</div>';
}
$header_top_menu_tree = module_exists('i18n_menu') ? i18n_menu_translated_tree('menu-header-top-menu') : menu_tree('menu-header-top-menu');
$variables['header_top_menu_tree'] = drupal_render($header_top_menu_tree);
// Process Slideshow Sub Header
if (theme_get_setting('sub_header') == 5 || arg(2) == 'sub-header' && arg(3) == '5') {
drupal_add_js(drupal_get_path('theme', 'stability') . '/vendor/jquery.glide.min.js');
}
if (theme_get_setting('retina')) {
drupal_add_js(drupal_get_path('theme', 'stability') . '/vendor/jquery.retina.js');
}
drupal_add_js(array('stability' => array('flickr_id' => theme_get_setting('flickr_id'), 'logo_sticky' => theme_get_setting('logo_sticky'))), 'setting');
}
示例8: iha_preprocess_page
function iha_preprocess_page(&$variables)
{
$search_box = drupal_render(drupal_get_form('search_form'));
$variables['search_box'] = $search_box;
if (drupal_is_front_page()) {
unset($variables['page']['content']['system_main']['default_message']);
//will remove message "no front page content is created"
drupal_set_title('');
//removes welcome message (page title)
}
if (arg(0) == 'node') {
$variables['node_content'] =& $variables['page']['content']['system_main']['nodes'][arg(1)];
}
if (isset($variables['node']->type)) {
$variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
}
// Prepare the mobile menu.
$user_menu = menu_tree('user-menu');
$main_menu = menu_tree('main-menu');
$menu_tree = array_merge($main_menu, $user_menu);
// FYI for future dev's - If need to add more menu items, then load the other menu through menu tree as well and do a
// array merge or for loop to attach the items to the $menu_tree.
$mobile_menu = '<ul class="list-unstyled main-menu">';
foreach ($menu_tree as $mlid => $mm) {
if (is_int($mlid)) {
$mobile_menu .= iha_render_mobile_menu($mm);
}
}
$mobile_menu .= '</ul>';
$variables['mobile_menu'] = $mobile_menu;
}
示例9: bodia_my_theme_preprocess_page
/**
* Preprocessor for page.tpl.php template file.
*/
function bodia_my_theme_preprocess_page(&$vars, $hook)
{
// For change title in node 3
if (arg(1) == 3 && arg(0) == 'node') {
$vars['title'] = 'Example template_preprocess_page';
}
// For easy printing of variables.
$vars['logo_img'] = '';
if (!empty($vars['logo'])) {
$vars['logo_img'] = theme('image', array('path' => $vars['logo'], 'alt' => t('Home'), 'title' => t('Home')));
}
$vars['linked_logo_img'] = '';
if (!empty($vars['logo_img'])) {
$vars['linked_logo_img'] = l($vars['logo_img'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home')), 'html' => TRUE));
}
$vars['linked_site_name'] = '';
if (!empty($vars['site_name'])) {
$vars['linked_site_name'] = l($vars['site_name'], '<front>', array('attributes' => array('rel' => 'home', 'title' => t('Home'))));
}
// Site navigation links.
$vars['main_menu_links'] = '';
if (isset($vars['main_menu'])) {
$vars['main_menu_links'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('id' => 'main-menu', 'class' => array('inline', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
}
$vars['secondary_menu_links'] = '';
if (isset($vars['secondary_menu'])) {
$vars['secondary_menu_links'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('id' => 'secondary-menu', 'class' => array('inline', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
}
}
示例10: cube_preprocess_page
/**
* Preprocessor for theme('page').
*/
function cube_preprocess_page(&$vars)
{
// Automatically adjust layout for page with right sidebar content if no
// explicit layout has been set.
$layout = module_exists('context_layouts') ? context_layouts_get_active_layout() : NULL;
if (arg(0) != 'admin' && !empty($vars['page']['right']) && (!$layout || $layout['layout'] == 'default')) {
$vars['theme_hook_suggestion'] = 'page__context_layouts_cube_columns';
drupal_add_css(drupal_get_path('theme', 'cube') . '/layout-sidebar.css');
}
// Clear out help text if empty.
if (empty($vars['help']) || !strip_tags($vars['help'])) {
$vars['help'] = '';
}
// Help text toggler link.
$vars['help_toggler'] = l(t('Help'), $_GET['q'], array('attributes' => array('id' => 'help-toggler', 'class' => array('toggler')), 'fragment' => 'help-text'));
// Overlay is enabled.
$vars['overlay'] = module_exists('overlay') && overlay_get_mode() === 'child';
if ($vars['overlay']) {
}
// Display user links
$vars['user_links'] = _cube_user_links();
// Display tabs
$vars['primary_tabs'] = menu_primary_local_tasks();
$vars['secondary_tabs'] = menu_secondary_local_tasks();
}
示例11: mothership_preprocess_page
function mothership_preprocess_page(&$vars, $hook)
{
// Define the content width
// Add HTML tag name for title tag.
$vars['site_name_element'] = $vars['is_front'] ? 'h1' : 'div';
// Classes for body element. Allows advanced theming based on context
// (home page, node of certain type, etc.)
$body_classes = array($vars['body_classes']);
if (!$vars['is_front']) {
// Add unique classes for each page and website section
$path = drupal_get_path_alias($_GET['q']);
list($section, ) = explode('/', $path, 2);
$body_classes[] = mothership_id_safe('page-' . $path);
$body_classes[] = mothership_id_safe('section-' . $section);
if (arg(0) == 'node') {
if (arg(1) == 'add') {
if ($section == 'node') {
array_pop($body_classes);
// Remove 'section-node'
}
$body_classes[] = 'section-node-add';
// Add 'section-node-add'
} elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
if ($section == 'node') {
array_pop($body_classes);
// Remove 'section-node'
}
$body_classes[] = 'section-node-' . arg(2);
// Add 'section-node-edit' or 'section-node-delete'
}
}
}
$vars['body_classes'] = implode(' ', $body_classes);
// Concatenate with spaces
}
示例12: template_preprocess_layout__double_fixed_inner_rev
/**
* Prepare variables for the drawer layout template file.
*/
function template_preprocess_layout__double_fixed_inner_rev(&$variables)
{
if ($variables['content']['sidebar'] && $variables['content']['drawer']) {
$variables['classes'][] = 'layout-both-sidebars';
} elseif ($variables['content']['sidebar'] || $variables['content']['drawer']) {
$variables['classes'][] = 'layout-one-sidebar';
if ($variables['content']['sidebar']) {
$variables['classes'][] = 'layout-has-sidebar';
} else {
$variables['classes'][] = 'layout-has-drawer';
}
} else {
$variables['classes'][] = 'layout-no-sidebars';
}
// Special handling for header image.
$variables['main_attributes'] = array('class' => array('l-content'));
if (arg(0) == 'user' && is_numeric(arg(1)) && !arg(2)) {
// We are on the user profile page.
$variables['main_attributes']['class'][] = 'account-page';
// Check to see if there is a profile image.
$account = user_load(arg(1));
// Entity cache should save us here?
if (isset($account->field_header_photo[LANGUAGE_NONE][0]['uri'])) {
// Generate an image at the correct size.
$image = image_style_url('header', $account->field_header_photo[LANGUAGE_NONE][0]['uri']);
$variables['main_attributes']['style'] = 'background-image: url(' . $image . ')';
// Add an addidional class.
$variables['main_attributes']['class'][] = 'has-background';
}
}
}
示例13: zen_preprocess_breadcrumb
/**
* Override or insert variables for the breadcrumb theme function.
*
* @param $variables
* An array of variables to pass to the theme function.
* @param $hook
* The name of the theme hook being called ("breadcrumb" in this case).
*
* @see zen_breadcrumb()
*/
function zen_preprocess_breadcrumb(&$variables, $hook)
{
// Define variables for the breadcrumb-related theme settings. This is done
// here so that sub-themes can dynamically change the settings under
// particular conditions in a preprocess function of their own.
$variables['display_breadcrumb'] = check_plain(theme_get_setting('zen_breadcrumb'));
$variables['display_breadcrumb'] = $variables['display_breadcrumb'] == 'yes' || $variables['display_breadcrumb'] == 'admin' && arg(0) == 'admin' ? TRUE : FALSE;
$variables['breadcrumb_separator'] = filter_xss_admin(theme_get_setting('zen_breadcrumb_separator'));
$variables['display_trailing_separator'] = theme_get_setting('zen_breadcrumb_trailing') ? TRUE : FALSE;
// Optionally get rid of the homepage link.
if (!theme_get_setting('zen_breadcrumb_home')) {
array_shift($variables['breadcrumb']);
}
// Add the title of the page to the end of the breadcrumb list.
if (!empty($variables['breadcrumb']) && theme_get_setting('zen_breadcrumb_title')) {
$item = menu_get_item();
if (!empty($item['tab_parent'])) {
// If we are on a non-default tab, use the tab's title.
$variables['breadcrumb'][] = check_plain($item['title']);
} else {
$variables['breadcrumb'][] = drupal_get_title();
}
// Turn off the trailing separator.
$variables['display_trailing_separator'] = FALSE;
}
// Provide a navigational heading to give context for breadcrumb links to
// screen-reader users.
if (empty($variables['title'])) {
$variables['title'] = t('You are here');
}
}
示例14: progressive_preprocess_page
/**
* Implementation of hook_preprocess_page().
*/
function progressive_preprocess_page(&$vars, $hook)
{
global $user;
if (arg(0) == 'user' && (arg(1) == 'register' || arg(1) == 'password' || arg(1) == '' && !$user->uid)) {
$vars['theme_hook_suggestions'][] = 'page__user__login';
}
}
示例15: boldy_preprocess_page
/**
* Override or insert PHPTemplate variables into the templates.
*/
function boldy_preprocess_page(&$vars)
{
$vars['tabs2'] = menu_secondary_local_tasks();
// Hook into color.module
if (module_exists('color')) {
_color_page_alter($vars);
}
// Classes for body element. Allows advanced theming based on context
// (home page, node of certain type, etc.)
$classes = explode(' ', $vars['body_classes']);
// Remove the mostly useless page-ARG0 class.
if ($index = array_search(preg_replace('![^abcdefghijklmnopqrstuvwxyz0-9-_]+!s', '', 'page-' . drupal_strtolower(arg(0))), $classes)) {
unset($classes[$index]);
}
if (!$vars['is_front']) {
// Add unique class for each page.
$path = drupal_get_path_alias($_GET['q']);
$classes[] = boldy_id_safe('page-' . $path);
// Add unique class for each website section.
list($section, ) = explode('/', $path, 2);
if (arg(0) == 'node') {
if (arg(1) == 'add') {
$section = 'node-add';
} elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
$section = 'node-' . arg(2);
}
}
$classes[] = boldy_id_safe('section-' . $section);
}
$vars['body_classes_array'] = $classes;
$vars['body_classes'] = implode(' ', $classes);
// Concatenate with spaces.
}