Now that layoutData is gone in GalleryEmbed, drupal integration look a bit weird now:
- I guess GalleryCapabilities::set('showSidebar', false) no longer work, it should use GalleryCapabilities::set('showSidebarBlocks', false);
- It seem that GalleryCapabilities::set('showPathbar', false); also no longer work, any workaround on this?
- In Drupal integration, we used to use the layoutData to set the page title as well as building the breadcrumb in Drupal, using the following code:
if (isset($result['layoutData'])) {
$urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
$breadcrumb = array(l(t('Home'), ''));
foreach ($result['layoutData']['parents'] as $parent) {
$breadcrumb[] = '<a href="'.$urlGenerator->generateUrl(array('itemId' => $parent['id'])) .'">'.$parent['title']."</a>";
}
drupal_set_breadcrumb($breadcrumb);
drupal_set_title($result['layoutData']['item']['title']);
}
Is there any way we can do it in the new theme system?
- Similiar, we also use the layoutData to build the navigation in Drupal, I guess now we can use the $data['showSidebarBlocks'] and extract the navigation block, but we no longer has the fine grain control on the layout because it will have the html code in there as well, and it become pretty ugly because it look a lots different than the rest of the site. (Drupal integration use the following code to generate the navigation
if (!$result['isDone'] && $result['layoutData']) {
$content = "<div class='menu'><ul>";
$list = array();
foreach ($result['layoutData']['itemLinks'] as $itemLink) {
$list[] = '<a href="'.$itemLink['url'] .'">'.$itemLink['text'] ."</a>\n";
}
foreach ($result['layoutData']['systemLinks'] as $systemLink) {
$list[] = '<a href="'.$systemLink['url'] .'">'.$systemLink['text'] ."</a>\n";
}
$content = $content . "</ul></div>";
$block['subject'] = t('gallery');
$block['content'] = theme('item_list', $list);
}
}
Anyway i can extract this information?
BTW, b4 rocks.
Regards,
-SY
Posts: 32509
- take a look at the sticky topic "Embedding and integration". i announce there changes.
e.g. you'll find there the sidebar stuff.
- pagetitle: use list ($title, $css, $js) = GalleryEmbed::parseHead($headHtml);
use css to change the look of the sidebar blocks / navigation. noone said you'd have to use the standalone, vanilla css for drupal.
i'd also recommend what the wpg2 devs did: develop a g2 theme for drupal.
Posts: 11
thx for the information on the pagetitle.
I did look at the "Embedding and integration" thread before i post this but I could not find the information regarding how to retrieve the layoutData as before ( i guess it is gone). So that's why I post this message.
While I understand that develop a theme specify for your site is the best solution. (I am running a modify version of Matrix since b3). IMHO: I still think that layoutData provide a more flexible option for me to tighyly integrate with the CMS, in this case, Drupal.
Just my 2 cents.
Anyway, go back to create my new theme then
Posts: 32509
yaus831, the layoutData approach was unique to the drupal integration. it was a hack, not documented etc. the same applies to the breadcrumb thing.
I understand that it's more flexible to assemble your own html. but it's also more demanding for the integration authors. if every integration has to retrieve the data from g2 and then generate it's own html, it would definitely very powerful, but it would take ages until an integration is finished.
so i'd see this layoutData (now it would rather be themeData) as a plus.
and i'd rather have some clearly defined API to get what you want instead of supplying the whole themeData, because the internal structure of the themeData can change without notice.
Posts: 32509
if you want to experiment a little, add
$data['themeData'] =& $template->getVariableByReference('theme');
right after line 313 of main.php
you can use var_dump($data['themeData']); to see what information is available.
Posts: 11
Why not provide both then? I understand that the gallery should responsible to handle gallery related request, encapsulate all the layout logic controlled by the theme system and return the output to external system. But why not provide both option so that if people want more flexibility, they can still retrieve that information throught $themeData or something, and aware the risk that the $themeData structure may change without notice. (I guess the structure is located in here; GalleryTheme::loadCommonTemplateData())
I can probably still achieve what I want previously by using pure CSS and custom theme, but it just look like more work: Drupal output its own breadcrumb, and gallery2 will output breadcrumb as well, in this case I will either disable the drupal breadcrumb and use the G2 breadcrumb when it is showing gallery2 related item or modify the theme in gallery 2 and use some css 'magic' to merge this 2 div/breadcrumb together. I guess it will work in the end, but it just look more complicated for something so simple before. (another way will be parse the bodyhtml, get the information we need (like the parseHead), and retrieve that information.)
I just track down the code in main.php, I guess i will do the hack on this one when I have time . (Or if we have GalleryEmbed::getThemeData() also sound nice )
Anyway, just my 2 cents.
Regards,
-SY
Posts: 11
lol, was typing the reply when you post this. Thx for the information. I will just do that.
Thanks for the great work in G2.
Regards,
SY
http://www.ocean.hk
Posts: 11
got it work now.. many thx.
Posts: 32509
i'm curious, how does your code look like?
Posts: 11
I have added the suggested line in main.php, then in gallery.module (the drupal integration) in function _gallery_handle_request()
then in gallery_block
The code look pretty much the same as before (b3), except that 'link' is no longer available in $systemLink and $itemLink and need to generate using the urlGenerator.
Posts: 32509
ok
IMO you could achieve almost the same if we offered GalleryEmbed::getBlockHtml('core.ItemLinks');
and then you'd use CSS to make it look like you want it to, given that the <div> around the itemLinks is selectable etc.
the same goes for breadcrumb and systemlinks.
Posts: 808
Is it still after line 313 in main.php that we have to add this?
$data['themeData'] =& $template->getVariableByReference('theme');
Also if this is the way we have to do this in Drupal can this be added to a module or something so that when we upgrade Gallery we don't have to add this line everytime.
Posts: 32509
yes you still have to do this.
please file a feature request. sure i could just add this line to main.php, but IMO we should solve this in a better way, and this will take some time.
Posts: 808
So it goes between these two lines
I just wanted to make sure that the lines in main.php changed in the last few weeks since I'm using RC1.
Posts: 32509
no, not there.
add it after these two lines:
$data = $theme->splitHtml($html, $results);
$data['isDone'] = false;
Posts: 808
It works now. Thanks valiant and yaus831. As you requested valiant I created RFE #1257054.
Posts: 10
Hi,
I am using a fresh Drupal v4.7.3- and Gallery 2.1.1-Installation. I am using the Hybrid-theme, because it fits very good into the Drupal-Layout and the Hybrid-pictureviewer is pretty handy. I got a php-error logged in drupal pointing to gallery.module line 218 wich starts the following foreach:
if (isset($result['themeData'])) { $urlGenerator =& $GLOBALS['gallery']->getUrlGenerator(); $breadcrumb = array(l(t('Home'), '')); foreach ($result['themeData']['parents'] as $parent) { $parent_title = $parent['title']; // Simple strip of bbcode (italics) $parent_title = str_replace("", "<i>", $parent_title); $parent_title = str_replace("", "</i>", $parent_title); $breadcrumb[] = '<a href="'.$urlGenerator->generateUrl( array('itemId' => $parent['id'])) .'">'.$parent_title."</a>"; }
The URL this error was produced from, is this one:
http://www.domain.tld/index.php?q=gallery&g2_itemId=123&g2_detail=1
The error is an invalid argument supplied for foreach. Its reason is, that for this URL $result['themeData'] has keys, but no ['parents']. For not removing the $breadcumb = array...-Code I just added another if-block around the for-block:
The error is gone and, as far as I can see right now, the code has no further effect on the module. I wrote this in a little naiv way, because I actually don't know neither Drupal-Coding, nor Gallery2-Coding. Just tried some direct PHP-correction for getting my installation to work.
so long,
Felix Lieb
--
YAFA - Yet Another Forum Account
Posts: 1
How can I get this line:
$urlGenerator =& $GLOBALS['gallery']->getUrlGenerator();
to use the gallery UrlRewrite functionality so shorturls are used in the Drupal breadcrumb?
Posts: 189
The latest CVS gallery module supports short URLs in the breadcrumb and is 4.7 compatible.