hey there,
I have written a module (TARDIS) that displays chronological lists of nodes using blocks and pages.
among other things, users can select the view mode to be displayed on the pages. but custom view modes cause the title to disappear.
I was really puzzled, so I created a custom view (using Views, really) in which I displayed nodes using custom view modes. to my surprise, the title disappeared from the view as well.
so, is this a known limitation of drupal_set_title()? what should I do to circumvent this? I thought about rendering a simple HTML like <h1>$title</h1>
but it shows up in the content section.
any help is greatly appreciated. thanks in advance!
Comments
A suggestion
Hello,
I believe you are comparing apples and oranges.
The method "drupal_set_title" sets a page attrbute.
Page.title is "apples" and node.title is "oranges". Nodes are not pages and pages are not nodes :) A page is a "html page" (a web page).
Content view modes set which node fields (attributes) are displayed. So I recommend inspecting the view mode (verify that node.title (remember that is different than page.title) is included, verify the node.title has a value).
Good Luck :)
hi @goofus, thanks for the
hi @goofus, thanks for the reply.
yes, I thought drupal_set_title() was meant to set both the H1 in the page (which I know differs from a node object) and the HTML title attribute.
since what my module does is basically build a query and present it as a page, it's important that both the page title and node titles show up on the right places. ;)
in fact, it works for node teasers, RSS and other view modes - but not Full node or custom view modes.
cheers,
Luciano
_________________________
"There is no off position on the genius switch."
- David Letterman
Another Suggestion
Hello,
Thank you for the reply.
I recommend inspecting the intermediate results. Either the title data is not present, or the display routine (E.G. theme) is not rendering the the title data. For example, you mentioned a query, does the query results contain the title data?
Next, I would set a break point on hook_entity_view and/or hook_node_view to see if there is any unexpected alterations occurring ( I.E. some module invoking something like hook_view_entity_alter().
Finally, I would set a break point in one the template.php functions. See if the title data has made it that far.
Once you locate where the issue is occurring, then you can detail a fix.
Good Luck :)
Another Suggestion
Hello,
Thank you for the reply.
I recommend inspecting the intermediate results. Either the title data is not present, or the display routine (E.G. theme) is not rendering the the title data. For example, you mentioned a query, does the query results contain the title data?
Next, I would set a break point on hook_entity_view and/or hook_node_view to see if there is any unexpected alterations occurring ( I.E. some module invoking something like hook_view_entity_alter().
Finally, I would set a break point in one the template.php functions. See if the title data has made it that far.
Once you locate where the issue is occurring, then you can detail a fix.
Good Luck :)
Gotta show us some code. If
Gotta show us some code. If your title is disappearing, check the following:
1) Is the title there, but hidden by CSS?
2) Are you calling drupal_set_title() somewhere?
3) Are you settings a variable that looks something like $var['#title'] to FALSE somewhere, in a preprocess or theme function?
4) Is the page title set? (the title in the browser)
@Jaypan, answering your
@Jaypan,
answering your questions:
1) Is the title there, but hidden by CSS?
nope. it won't show up at all when nodes are rendered as Full node or a custom view mode. other view modes, like teaser and RSS, work as expected.
2) Are you calling drupal_set_title() somewhere?
yep, please check the code below.
3) Are you settings a variable that looks something like $var['#title'] to FALSE somewhere, in a preprocess or theme function?
no. also, there's no preprocess functions and minimal theming.
4) Is the page title set? (the title in the browser)
yes it is.
here's the function that builds a TARDIS page:
(the relevant stuff is from the first occurence of drupal_set_title() on.)
thanks for the assistance!
cheers,
Luciano
_________________________
"There is no off position on the genius switch."
- David Letterman
oops
sorry, folks. I installed a fresh copy of D7 (with my module) in a local environment, re-did my steps, and the problem vanished. it wasn't there.
I guess it might be related to my webhost, but whatever it is it's not related to Drupal.
anyway, thanks for the assist!
cheers
_________________________
"There is no off position on the genius switch."
- David Letterman