Appending the Slideshow link to have a named anchor

globalnet

Joined: 2004-09-23
Posts: 5
Posted: Sat, 2010-05-01 06:18

I have gallery embedded in a Joomla page, and due to the amount of content above the gallery, I need to change the "View Slideshow" url from (for example):
http://mysite.com/somegallery/?g2_view=slideshow.Slideshow&g2_itemId=884
to:
http://mysite.com/somegallery/?g2_view=slideshow.Slideshow&g2_itemId=884#namedanchor

I have looked all through the files and have been unable to find what to edit. I have the anchor in place, all that remains is this link. The slideshow version if it matters is 1.0.5.1 run in the Matrix theme.

Any help is appreciated.

Cheers,
Mike

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2010-05-01 12:21

I just happen to have put out an update to that module yesterday.
To alter the itemLinks look to modules/slideshow/module.inc

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
globalnet

Joined: 2004-09-23
Posts: 5
Posted: Sat, 2010-05-01 13:15

Thanks for the tip, I have found this bit of code, which I'm pretty sure is what forms the link:

/**
* @see GalleryModule::getItemLinks
*/
function getItemLinks($items, $wantsDetailedLinks, $permissions) {
$links = array();
foreach ($items as $item) {
$itemId = $item->getId();
if (isset($wantsDetailedLinks[$itemId])) {
$links[$itemId][] =
array('text' => $this->translate('View Slideshow'),
'params' => array(
'view' => 'slideshow.Slideshow','itemId' => $itemId));
}
}
return array(null, $links);
}

I have tried the add in the anchor but I'm afraid I just don't know enough php to figure out how to add that in on the end of the array after the itemID. Any advice?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2010-05-01 13:36
$links[$itemId][] =
array('text' => $this->translate('View Slideshow'),
'params'=> array('view' => 'slideshow.Slideshow',
'itemId' => $itemId, 'return' => $returnUrl));

I forgot we were just returning parameters and not a fully constructed link.
you can try to add your own parameter:

$links[$itemId][] =
array('text' => $this->translate('View Slideshow'),
'params'=> array('view' => 'slideshow.Slideshow',
'itemId' => $itemId, 'return' => $returnUrl, '#namedanchor' => ''));

but a g2_ will be prepended in the final link - but it won't hurt to try.

The other place would be in the template(s)
themes/your theme/templates/album.tpl and photo.tpl
and modules/core/templates/blocks/ItemLinks.tpl

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
globalnet

Joined: 2004-09-23
Posts: 5
Posted: Sat, 2010-05-01 15:51

No such luck. The url is still malformed. Any other suggestions?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2010-05-01 16:18

G2 doesn't support anchors (url fragments, I'm told they should be called.) In June 2008 I submitted for code review by the core team the modifications to support them but it was too late for the G2.3 cut-off, and we know what happened to G2.4...

Unfortunately there doesn't appear to be access to the ccollab website that the G2 team used anymore, otherwise you could have installed the code mods in your own installation. If anyone knows how to get access to that system let me know...

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2010-05-01 17:52

Are you talking about http://reviews.gallery2.org/ ?
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2010-05-01 18:01

I'm wondering if you could use the href param:

$links[$itemId][] =
array('text' => $this->translate('View Slideshow'),
'params'=> array('href' => 'g2_view=slideshow.Slideshow&g2_itemId='.$itemId.'&g2_return='.$returnUrl.'#namedanchor'));

basically building the url yourself.

Or use jQuery or other js to append what you need <- prolly what I'd do.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2010-05-01 19:21
nivekiam wrote:
Are you talking about http://reviews.gallery2.org/ ?

Yes - service temporarily unavailable.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2010-05-01 22:22

I've reported the issue with that site.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2010-05-03 16:10

Probably overkill but you can modify GalleryUrlGenerator.class to allow the creation of anchors/fragments:

	
676	        /*
677	         * controllers can't return options, only parameters
678	         * so allow use of a 'fragment' parameter instead of option
679	         */
680	        if (isset($params['fragment'])) {
681	            $options['fragment'] = $params['fragment'];
682	            unset($params['fragment']);
683	        }
684	       
685	        /* Add parameters to URL */
686	        $url = GalleryUrlGenerator::appendParamsToUrl($url, $params, true,
687	            !empty($options['htmlEntities']) || !isset($options['htmlEntities']),
688	            !empty($options['urlEncode']) || !isset($options['urlEncode']));
689	  
690	        /* Add embed session parameters to URL */
691	        if (!empty($embedSessionParams)) {
692	            $url = GalleryUrlGenerator::appendParamsToUrl($url, $embedSessionParams, false,
693	                !empty($options['htmlEntities']) || !isset($options['htmlEntities']), false);
694	        }
695	       
696	        /* Add URL fragment identifier */
697	        if (isset($options['fragment'])) {
698	            $url .= '#' . ((!empty($options['urlEncode']) || !isset($options['urlEncode']))
699	                                 ? urlencode($options['fragment'])
700	                                 : $options['fragment']);
701	        }
702	  
703	        /* Replace protocol with $options['protocol'].  See RFC1738 section 2.1. */
704	        if (isset($options['protocol'])) {
705	            $url = preg_replace('/^[a-zA-Z0-9\+\.\-]+:/', $options['protocol'] . ':', $url);
706	        }
707	  

The new parts are 676-683 and 696-701. Syntax is then (as per the example above):

Quote:
$links[$itemId][] =
array('text' => $this->translate('View Slideshow'),
'params'=> array('view' => 'slideshow.Slideshow',
'itemId' => $itemId,
'return' => $returnUrl,
'fragment' => 'namedanchor'));

Test and use at your own risk.