add item on the bottom level photo page in addition to the album level.

yasha

Joined: 2004-11-05
Posts: 40
Posted: Thu, 2008-09-11 16:17

Hi,
Please see www.projectflag.net
you may login with user: rozov pass: flag38
click on the usa flag. as you can see ive setup the album to go directly to the photopage as i have microthumbs navigation. if you click on 'usa' on the breadcrumb you will get the album level which enalbles you to add item to the album. since most of my users will go directly to the photo page id like them to be able to add another photo to the album from that page. can someone help?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2008-09-11 23:21

Quick and dirty?

Globally: Site Admin > Themes > select your theme

In the Blocks to show on photo pages section add Item Actions

At the album level: Edit Album > Theme > pretty much the same at this point

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
yasha

Joined: 2004-11-05
Posts: 40
Posted: Fri, 2008-09-12 13:20

Thanks Nivekiam.
I think I didnt make myself understood..
'Item actions' allows to manipulate items that already exist. inside that block there is no option for adding a new item.

i would like to have a menu option which i do have at the album level - the option of adding an item to the parent album when im viewing a full size photo.. As many times my users will skip the intermediate album view (where you see thumbnails of all the photos in the album) and go directly from clicking on the album's thumbnail to the 1st photo of the album.

see www.projectflag.net
you may login using name: rozov pass: flag38
click on the USA album (just that one..). to see the album thumbnails backup by clicking on the USA in the breadcrumb.

thanks for your help! Yasha.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Fri, 2008-09-12 16:04

No, you made yourself clear, I wasn't thinking straight ;)

edit photo.tpl, be sure to follow the directions at the top about creating a local directory and putting your changes there

add this, the important parts are highlighted in red, feel free to change the class names, div, etc, but I'd probably leave the Add a photo part as that should automatically get translated into what ever language your user's have set.

        <div class="gbBlock giDescription">
          {if isset($theme.permissions.core_addDataItem)}
          <br/>
          <a href="{g->url arg1="view=core.ItemAdmin" arg2="subView=core.ItemAdd" arg3="itemId=`$theme.item.parentId`"}"> {g->text text="Add a photo!"} </a>
          {/if}
        </div>

I took that code from album.tpl and change $theme.item.id to $theme.item.parentId You can find out which variables are available by default by putting Gallery into debug mode and taking a look at the Smarty Debug Console popup window.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
yasha

Joined: 2004-11-05
Posts: 40
Posted: Sat, 2008-09-13 13:16

Thanks for this nivekiam,
Im having some trouble. Ive tried to paste the code into at least three places in the photo.tpl template. not getting any results...(ive put it into the local folder)

also, optimally id like the "add photo" to show up in the same place the "add item" shows up at the album level. i assume this is the navigatorTop.tpl - so code-wise i guess we would have to create an instance where gallery determines whether we are at the album level or the photo level and uses the relevant script? Again, it works perfect at the album level (USA) if you login using details in the post above. thanks a bunch, Yasha.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2008-09-13 14:06

Have you tried clearing your template cache? Site Admin > Maintenance > Clear Template Cache

The second part all depends on your theme. I'm not familiar with the X_treme theme. The last time I used it, it was (and probably still is) a complex, bloated, hard customize theme. At least it looks like the files have been cleaned up and are a bit easier to read. Still very bloated though and I couldn't even imagine trying to make changes and maintaining them in the future. Crips!!! the theme is a 1.7MB download, that's larger than the core of Drupal or Wordpress. Yeah, very bloated IMO. I like modularity where I can pick and choose my functionality and make something do what I want, with less. Not the "everything, plus the kitchen sink, plus 50 suit cases for a 2 day trip" mentality ;)

It is a very nice looking theme with a lot of options, too many IMO that make it a real pain to use.

I'd start by looking at the album.tpl, navigatorTop.tpl is an X_treme theme specific page and I have no idea what it's for. By the name I can only assume it's purely for navigation and probably not what you're looking for, but again, I don't know the theme and I'm not going to take the time to learn it.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sat, 2008-09-13 14:59

Here's another way of doing it that doesn't involve any mucking around with templates at all. Put this code in a file called module.inc inside a new directory called 'extraadditem' in the /modules folder, then install it from the plugins page (it will appear at the bottom.)

<?php 
class ExtraAddItemModule extends GalleryModule {

    function ExtraAddItemModule() {
	$this->setId('extraadditem');
	$this->setName('extraadditem');
	$this->setDescription('Add add-item link to photos');
	$this->setVersion('0.1.0');
	$this->setCallbacks('getItemLinks');
	$this->setRequiredCoreApi(array(7, 4));
	$this->setRequiredModuleApi(array(3, 0));
    }

   function getItemLinks($items, $wantsDetailedLinks, $permissions) {
	
	GalleryCoreApi::requireOnce('modules/core/module.inc');
	$core = new CoreModule;
	$links = array();
	foreach ($items as $item) {
	    $itemId = $item->getId();
	    if ($item->getCanContainChildren() || !isset($wantsDetailedLinks[$itemId])) {
		continue;
	    }
    	    $parentId = $item->getParentId();
    	    if (!GalleryCoreApi::hasItemPermission($parentId, 'core.addDataItem')) {
	    	continue;
    	    }
    
	    $links[$itemId][] = array('text' => $core->translate('Add Items'),
			  'params' => array('view' => 'core.ItemAdmin',
					    'subView' => 'core.ItemAdd',
					    'itemId' => $parentId,
					    'return' => 1));
	}
	return array(null, $links);
    }
}
?>

You'd better check that the permissions checks are quite correct, too.

EDIT: uses core translation of 'Add Items' now.
EDIT #2: no need actually to fetch the parent.

 
yasha

Joined: 2004-11-05
Posts: 40
Posted: Sat, 2008-09-13 23:37

nivekiam,
I hear what you're saying. im having thoughts of repentance. This is going to be a big project and i dont want to risk using a theme that's difficult to work with and slow. Ill probably try using carbon or ice. I just dread the thought of trying to make everything look and work more or less the way it is now - your opinion - you think possible? In any case if i do allow me to ask you at some point where to insert your code in the photo.tpl for carbon. Many thanks again, Yasha.

alec Thanks so much for your response. Ive tried it and the menu item appears in the drop down box. so far so good. one question/request though.. since the action is not item specific (i.e. were not adding an item to the specific photo shown but rather adding another photo to the parent album from the occassional photo page) it would make sense for me to have this as a link at the top (where we see " Site Admin | Your Account | Logout " - basically as it appears at the album level..how would i enable this with the link context (album) sensitive..? thanks for your help, yasha.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2008-09-13 23:37

Anything is possible, but if X_treme theme has everything you want, then I'd probably stick with it. Note any and all of the changes you make so that you can re-apply them if a new version of the theme is released or a new version of gallery is released that makes the theme incompatible, forcing you to upgrade.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2008-09-14 08:45
yasha wrote:
alec Thanks so much for your response. Ive tried it and the menu item appears in the drop down box. so far so good. one question/request though.. since the action is not item specific (i.e. were not adding an item to the specific photo shown but rather adding another photo to the parent album from the occassional photo page) it would make sense for me to have this as a link at the top (where we see " Site Admin | Your Account | Logout " - basically as it appears at the album level..how would i enable this with the link context (album) sensitive..? thanks for your help, yasha.

I think what you're looking for is Add Items as a systemLink (see http://codex.gallery2.org/Gallery2:ModuleLinks - it always helps to use the right terminology especially since different themes put the different kinds of link in different places.)

Unfortunately there's no context supplied when systemLinks are gathered, so no way to enable/disable it based on the item on the page. Also - this is just my opinion - it's not necessarily desirable, since canonically Add Items appears as an itemLink, at least on album pages, and consistency is very important. So you're sol on that approach - back to tinkering with templates!

 
yasha

Joined: 2004-11-05
Posts: 40
Posted: Sun, 2008-09-14 09:31

Thanks Alec. :)

 
liberte

Joined: 2004-10-10
Posts: 9
Posted: Tue, 2008-09-23 21:51

Thanks for the code nivekiam, the first block of code worked for me (using 'item.id' instead of 'item.parentId').

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Thu, 2008-09-25 14:02

@ Alec: your option seems to work (I get at least the option of adding pictures at the boottom of the screen. However when logged in as Admin, I get the following message:

Error Detail  -
Error (ERROR_BAD_PARAMETER)

    * in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 39 (gallerycoreapi::error)
    * in modules/core/classes/GalleryCoreApi.class at line 2259 (galleryentityhelper_simple::loadentitiesbyid)
    * in modules/core/ItemAdmin.inc at line 38 (gallerycoreapi::loadentitiesbyid)
    * in modules/core/classes/GalleryView.class at line 300 (itemadminview::loadtemplate)
    * in main.php at line 445 (itemadminview::doloadtemplate)
    * in main.php at line 94
    * in main.php at line 83

System Information
Gallery version 	2.2.4
PHP version 	4.4.8 apache
Webserver 	Apache/1.3.39 (Unix) mod_ssl/2.8.30 OpenSSL/0.9.7e-p1 PHP/4.4.8 FrontPage/5.0.2.2510
Database 	mysqlt 5.0.51a
Toolkits 	Gd
Operating system 	FreeBSD server.superhost2.nl 6.2-STABLE-200708 FreeBSD 6.2-STABLE-200708 #0: Fri Aug 17 07:22:26 UTC 2007 :/usr/obj/usr/src/sys/SMP amd64
Browser 	Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080219 Firefox/2.0.0.12 Navigator/9.0.0.6 

When logged in as user, the following message appears

Security Violation

The action you attempted is not permitted. 

Any idea what can be wrong?

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Tue, 2008-09-30 19:49

Just a little bump to see if there is someone online who can help me with the above question....

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2008-09-30 20:04

Since that worked for someone else, I can only think that either there is a problem with the file you uploaded from copying and pasting that code of Alec's, or that there is some incompatibility with that code and 2.2.4. Maybe try upgrading to 2.2.6, though the differences should really only be bug and security fixes and not changes to the API.

Maybe, try the option I posted above: http://gallery.menalto.com/node/81487#comment-285734

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Sun, 2008-10-05 08:30

You're right nivekiam, but I have to admit that I mixed things up; I installed Alec's option at the same time as your suggestion. And I just misinterpreted the both of them.

So the error appears with the solution you provided, not with Alec's... well at least one of the options works for me, although I think your solution would be more clear to the users I have to instruct (no need for extra diving into menu's), I can't get it to work (did try the change between Item.Id and Item.ParentId) and don't know how to make it work either...

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2008-10-05 16:34

I just tried my modification on my gallery and it worked. Maybe there was a mistake when copying and pasting or maybe it had to do with your text editor? Can you post your photo.tpl file? You might need to rename it to photo.txt.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Mon, 2008-10-06 15:41

Attached you can find the photo.tpl (for this purpose indeed renamed to photo.txt) I used... The code is starting in line 82, I used also a version with theme.item.id with the same result.
Access rights given are:

- add subitem
- delete item
- change item

(I hope I made the right translations, am using a localised version in Dutch here)

So the link is displayed correctly, but get the error as mentioned above when logged in as admin and the error below when logged in as user...

Your help is highly appreciated!

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2008-10-06 16:59

On line 85 you have
{g- >text

NOTE the space between g- > there should be no space at all there.

{g->text

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Mon, 2008-10-06 20:53

I'm sorry, I adjusted that, but it doesn't make any difference...

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2008-10-06 21:05

Since we're dinking around with templates. First clear the template cache, Site Admin > Maintenance > Clear Template Cache and see if that works. If not, try the attached file, don't edit it, don't open it and save it, just rename it to photo.tpl and upload that.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Tue, 2008-10-07 15:51

I just performed both actions without any positive result unfortunately....I'm sorry...

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2008-10-07 16:02

Well I didn't suggest this earlier because I couldn't see what would possibly be different between 2.2.4 and 2.2.6, but you should upgrade anyway to get the security fixes.

Can you also post a link to your site? I'll see if I can find anything from poking around and ask for more info if needed.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Tue, 2008-10-07 16:12

OK, I'll try to do the upgrade this evening, link to the website = Alphoto

Do you want me to give you some temporary background access? (which I send you in private of course)

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2008-10-07 17:13

Yes, can you create a temporary use that has site admin access and send that in private? I've poked around as much as I can, trying your template changes (the ones I can find) on my gallery and everything works for me.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2008-10-07 18:17

Got your message. I see now, well I think I do. For some reason $theme.item.ParentId doesn't exist. Would it be possible for you to put Gallery into Debug Mode so I can see the Smarty Template debug console? I don't know where you are at in the world, but if now isn't a good time for that as it would mess with the Gallery for all visitors, then let me know when a good time would be for you in your time zone.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2008-10-07 18:17

PS Here's how to put Gallery into Debug Mode: FAQ: How to set/use Gallery in debug mode?
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Tue, 2008-10-07 19:15

OK now... successfully upgraded to 2.2.6 , and we are now in Debug Mode.... ;)

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Tue, 2008-10-07 19:30
nivekiam wrote:
Got your message. I see now, well I think I do. For some reason $theme.item.ParentId doesn't exist. Would it be possible for you to put Gallery into Debug Mode so I can see the Smarty Template debug console? I don't know where you are at in the world, but if now isn't a good time for that as it would mess with the Gallery for all visitors, then let me know when a good time would be for you in your time zone.

Hmm..strange, but glad you found at least a lead to the problem. I'm in Europe, so it's 21.30PM now in the evening. No problem for me if you poke around now, although I hope that I still have a working G2-install tomorrow-morning... :-)))

As mentioned earlier, G2 is updated to the most recent version, and in Debug Mode at this very moment.

Good luck!

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2008-10-07 20:41

You have nothing to worry about. I won't harm your gallery at all.

I didn't notice this before. Change $theme.item.ParentId to $theme.item.parentId (notice the lowercase 'p'
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2008-10-07 20:52

PS. It must've worked for me in the past on my Gallery install because I must not have cleared my template cache.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Tue, 2008-10-07 21:03

OK, great. I'll change the case of the ParentId to parentId and then switch off Debug-mode; I'll let you know what my findings are...

 
mikekiwi

Joined: 2005-08-20
Posts: 27
Posted: Tue, 2008-10-07 21:11

A few minutes later: Yep, this works very good now! LowerCase is BigDifference!

Many thanks for your time on behalf of everyone of my photoclub for having now an easy to accomplish upload-feature. Great!!!