2

I have one node type and two page types for this node.

http://site.com/themes/*

and

http://site.com/years/*

And i want to hide one of the "view-filed" in all "years" pages using the css.

Found this but it doesn't work

function mythemename_preprocess_page(&$variables,$hook) {
  $alias = explode('/',drupal_get_path_alias(request_uri()));
  if($alias[1]== "years") {
   $vars['theme_hook_suggestions'][] = 'years';
  }
}

https://groups.drupal.org/node/130944#comment-762483

I would be very grateful for any help.

1
  • Do you have a URL we can look at? Jul 24, 2013 at 18:49

2 Answers 2

1

Here's how I would do it (but I'm rather new to this, so maybe your approach is better)...

function mythemename_preprocess_page(&$vars, $hook) {
  if (arg(0) == 'years') {
    drupal_add_css(path_to_theme().'/css/years.css');
  }
}
2
  • The stylesheet links have already been rendered when the *_preprocess_page() functions get called. As far as i know the only way to use your code it is to make custom module because modules renders earlier. But i dont want module. I solved my problem by creating separate blocks for each type of page.
    – one2gov
    Jul 24, 2013 at 19:09
  • Cool - glad you found a solution. For the record, you can specify group and weight by doing something like this... function mythemename_preprocess_page(&$vars, $hook) { if (arg(0) == 'years') { drupal_add_css(path_to_theme().'/css/years.css', array( 'group' => CSS_THEME, 'weight' => '100',) ); } } Jul 24, 2013 at 19:42
-1

I would suggest doing this with pure CSS selectors.

I'm pretty sure you can do something like this:

/* Hides the link text. */

a[href*="find_this_part_of_URL"] {

display: none;

}

I suggest you do NOT hide page content with this CSS, as it is bad for search engine optimization, but if you honestly can't get the theme to cover up a link, so you can focus on fixing the theme hook, use the above code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.