From mail@webthatworks.it Tue May 5 16:19:45 2009 From: Ivan Sergio Borgonovo To: development@drupal.org Subject: [development] global object to push stuff into Date: Tue, 05 May 2009 18:19:07 +0200 Message-ID: <20090505181907.745845b2@dawn.webthatworks.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3003500232783837908==" --===============3003500232783837908== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit I was looking at nodewords (aka Meta tags) and I developed my own mini module to push stuff into . nodewords grab informations from "core" or very popular modules to add stuff into meta and it provides a basic api to other modules. But somehow meta are a standard part of a web page and drupal provide just drupal add_html_head/drupal_get_html_head. So there is no way to edit in a structured way head. A common use would be to add keywords or replace them and support keywords/description for content that is not node-based. If there was such a structured object to deal with META it would be easier for modules and non-node content to place stuff there. And in spite of writing an "additional" snippet of code to nodewords to support different modules, other modules will just have to pass what they want to this object. I already wrote a module that provide such object to give a structured access to HEAD and provide some helper to easily access, overwrite, add description, keywords and canonical url + support for nearly arbitrary head tags. I`m going to build up a nodewords clone to experiment with an hybrid approach that will offer modules to push stuff into HEAD and pull stuff from core object as nodewords already does. Of course I already have some other module that push stuff into meta. There could be a head_alter hook or something similar. I was wondering if a more structured access to HEAD would gain any traction in core or there is already someone working on it to get an idea of the direction core may take. thanks -- Ivan Sergio Borgonovo http://www.webthatworks.it --===============3003500232783837908==-- From jeff@viapositiva.net Tue May 5 16:42:18 2009 From: Jeff Eaton To: development@drupal.org Subject: Re: [development] global object to push stuff into Date: Tue, 05 May 2009 11:41:47 -0500 Message-ID: In-Reply-To: <20090505181907.745845b2@dawn.webthatworks.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7586745424950743390==" --===============7586745424950743390== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On May 5, 2009, at 11:19 AM, Ivan Sergio Borgonovo wrote: > So there is no way to edit in a structured way head. In Drupal 7, I'd really love to see the globally alterable $page array become a place where this stuff lives. hook_page_alter already exists... --Jeff --===============7586745424950743390==-- From mail@webthatworks.it Wed May 6 02:03:03 2009 From: Ivan Sergio Borgonovo To: development@drupal.org Subject: Re: [development] global object to push stuff into Date: Wed, 06 May 2009 04:02:27 +0200 Message-ID: <20090506040227.6f6deb06@dawn.webthatworks.it> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5779578604489797400==" --===============5779578604489797400== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On Tue, 5 May 2009 11:41:47 -0500 Jeff Eaton wrote: > On May 5, 2009, at 11:19 AM, Ivan Sergio Borgonovo wrote: > > > So there is no way to edit in a structured way head. > > In Drupal 7, I'd really love to see the globally alterable $page > array become a place where this stuff lives. hook_page_alter > already exists... OK... the method to write there is getting simpler and simpler but there is still just a drupal_get_html_head in D7 too. I`d say is just a matter of giving a more fine grained structure to head. Is there anything else worth to support other than: META http://www.w3.org/TR/REC-html40/struct/global.html#h-7.4.4 LINK http://www.w3.org/TR/html401/struct/links.html rendering an arrays that represent the above shouldn`t be hard. I think we can`t have a pure push or pull approach eg. for description. Taxonomy may decide to fill description but the administrator may like to have a description formed by node title + taxonomy terms or node title and publishing date etc... Anyway having a more structured HEAD may help both push and pull approach. eg. a module that doesn`t produce nodes but just "pages" may decide to push some content in the META description. An "arbitrator" as nodewords may decide to pull from nodes and taxonomies (views etc...) some information, mix it in the description. Another module may act just before page rendering and concatenate some more stuff to what the "arbitrator" did. eg. "Lamborghini Countach in Cars ยป Sport Cars, hot topic" title + taxonomy + added by module Anyway accessing a standard array may help modules interact better. Somehow my "home-brewed" module already offers a global object which store an array and offer some methods to deal with the most common operations on keywords and description and then, at least for D5 I added some code in the page template. In D6 I could use prerender hook. -- Ivan Sergio Borgonovo http://www.webthatworks.it --===============5779578604489797400==-- From mail@webthatworks.it Thu May 7 15:18:20 2009 From: Ivan Sergio Borgonovo To: development@drupal.org Subject: [development] drupal_add_head -> $page[hook_alter_page Re: global object to push stuff into Date: Thu, 07 May 2009 17:17:35 +0200 Message-ID: <20090507171735.3308ce41@dawn.webthatworks.it> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8922703668767904656==" --===============8922703668767904656== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Tue, 5 May 2009 11:41:47 -0500 Jeff Eaton wrote: > On May 5, 2009, at 11:19 AM, Ivan Sergio Borgonovo wrote: > > > So there is no way to edit in a structured way head. > In Drupal 7, I'd really love to see the globally alterable $page > array become a place where this stuff lives. hook_page_alter > already exists... I was giving a look to the current status of D7 and trying to understand how to put stuff in the $page. I like the $page approach too compared to the drupal_add_* since $page doesn`t look as a global (am I right?) There are really few places that use _page_alter that could be a guide to understand how $page look like. book_page_alter (no use) block_page_alter Furthermore I think that just finding a place in $page is solving half the problem. I can`t think of any way a _page_alter could get the content of a *part* of a page and modify it that could be general enough to provide some standard method to help modifying it. I`m just guessing since it seems to appear that a $page is mainly constituted by regions and blocks but then everything become arbitrary html. But head has a more regular content with some rules that makes some modifications meaningless and somehow can contain much less variety. Maybe a set of helpers that will make it easy to access/modify a $page['head'] and every module that need to modify head could do so in hook_alter_page? Having a structured head implies having a renderer/theme function (am I right?) This should support everything that already ends up in head... namely LINK [1] and META Is there anything else that could end up in head? I didn`t see anything else at w3c. META http://www.w3.org/TR/REC-html40/struct/global.html#h-7.4.4 LINK http://www.w3.org/TR/html401/struct/links.html Maybe we could have a structured $page['head'][..] + an unstructured $page['head']['markup'] There is also this "orphan": meta_generator_header that could be treated more uniformly thanks for any input BTW I`ve noticed that head is filled several times (?) by: system_preprocess_page emplate_preprocess_book_export_html template_preprocess_maintenance_page and template_preprocess_page is it correct? [1] is it ok to use drupal_add_html_head in openid_test_html_openid1 openid_test_html_openid2 openid_test_yadis_http_equiv in spite of drupal_add_link ? -- Ivan Sergio Borgonovo http://www.webthatworks.it --===============8922703668767904656==-- From weitzman@tejasa.com Thu May 7 15:28:15 2009 From: Moshe Weitzman To: development@drupal.org Subject: Re: [development] drupal_add_head -> $page[hook_alter_page Re: global object to push stuff into Date: Thu, 07 May 2009 11:27:25 -0400 Message-ID: <6117a7500905070827s6b5ce100yc9b10ab82948c969@mail.gmail.com> In-Reply-To: <20090507171735.3308ce41@dawn.webthatworks.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3517888322850957974==" --===============3517888322850957974== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit > Having a structured head implies having a renderer/theme function (am > I right?) yes. but core provides some basic ones like #markup so we may not need anything new. a $page['head'] array sounds good to me. --===============3517888322850957974==-- From mail@webthatworks.it Thu May 7 19:52:49 2009 From: Ivan Sergio Borgonovo To: development@drupal.org Subject: [development] drupal_add_head -> $page[ 'head'] and hook_alter_page was: Re: global object to push stuff into Date: Thu, 07 May 2009 21:52:11 +0200 Message-ID: <20090507215211.21d23250@dawn.webthatworks.it> In-Reply-To: <6117a7500905070827s6b5ce100yc9b10ab82948c969@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2396372398503157900==" --===============2396372398503157900== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Thu, 7 May 2009 11:27:25 -0400 Moshe Weitzman wrote: > > Having a structured head implies having a renderer/theme > > function (am I right?) > > yes. but core provides some basic ones like #markup so we may not > need anything new. ? > a $page['head'] array sounds good to me. $page = array( 'head' => array( '#markup' => '', 'meta' => array( ... ); theme_head($head) { foreach(...) { } unset($head['meta']); foreach(...) { } unset($head['link']); ... $output .= drupal_render($head); // should we really be so verbose? ... } Other than concat, overwrite what could be done with stuff in head? I`m just aware of LINK and META and I`m abandoning the idea to offer some helper function. It doesn`t seem to have any meaning eg. to duplicate http-equiv since we can actually send headers. So if I would like to implement this change I should: 1 double-check what can be placed in head 2 document the structure of page I`m going to use 3 provide a theme_head 4 substitute all the occurrence of drupal_add_html_head with hook_alter_page (including stuff in drupal_add_link) [1] 5 change all the occurrences of drupal_get_html_head with ??? [2] [1] this looks like a revolution and somehow it may end up in changing head out of context. In core there are few uses of drupal_add_html_head I`d say that _alter_page doesn`t look the only candidate where to put stuff that change head. keywords and description are generally related to content, you generate content in the main menu callback function and there you may collect the right information to build up keywords, description, ranking... If we need to change head other than with _alter_page what other choices are available? [2] Actually... drupal_get_html_head is mainly used in *_preprocess_page... but how other things end up there? Most of the things that end up in _preprocess_page are globals. I`m wondering if putting stuff in $page is really worth the effort... after all $head could be just another global, just structured. Am I missing something? $page doesn`t look to be a global, couldn`t other stuff slowly end there too in spite of having tons of functions containing static? /me fighting with claws-mail on sid that for some strange reason transformed the ' key (not the character) into a greedy ^W BTW function template_preprocess_page(&$variables) { $variables['css'] = drupal_add_css(); $variables['styles'] = drupal_get_css(); ?? is it right? -- Ivan Sergio Borgonovo http://www.webthatworks.it --===============2396372398503157900==--