Remove Add Album to Cart on Front Page ONLY

Another_Matt

Joined: 2009-08-20
Posts: 40
Posted: Wed, 2009-09-16 17:54

Ello, I'm trying to remove the "Add Album to Cart" link from my albums on the front page only. I need it on sub-albums. The only solution I've seen is http://gallery.menalto.com/node/35784 which takes it away entirely. I'm running Matrix on 2.3. Thanks for any solutions.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 22888
Posted: Thu, 2009-09-17 03:02
  {if empty($theme.parents)}
  {if $theme.pageType != 'admin'}
  stuff on root album only and not a admin page
  {/if}
  {/if}

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Another_Matt

Joined: 2009-08-20
Posts: 40
Posted: Thu, 2009-09-17 13:48

Thanks for the quick response Dave. I played with it and can't figure out how to properly add the code. My basic argument here is "For each item that is on root/admin page display nothing ELSE display Add to Cart links" How do I add that?

Original Code

Quote:
function getItemLinks($items, $wantsDetailedLinks, $permissions) {
$links = array();
foreach ($items as $item) {
if (isset($permissions[$item->getId()]['cart.add'])) {
$itemTypeNames = array_merge($item->itemTypeName(), $item->itemTypeName(false));
if (false) {
/* Specific translations: */ _('Add Album To Cart'); _('Add Photo To Cart');
}
$links[$item->getId()][] =
array('text' => $this->_translate(
array('text' => 'Add %s To Cart',
'arg1' => $itemTypeNames[0]), $itemTypeNames[2]),
'params' => array('controller' => 'cart.AddToCart',
'itemId' => $item->getId(), 'return' => true));
} }

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 22888
Posted: Thu, 2009-09-17 23:53

What theme are you using?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Another_Matt

Joined: 2009-08-20
Posts: 40
Posted: Fri, 2009-09-18 03:20

Matrix running on Gallery 2.3

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 22888
Posted: Sat, 2009-09-19 05:17

I never use the cart module so did not notice it is a permissions issue.
Edit permissions on the root album, remove
[cart] Add to cartfrom the Everybody group.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Another_Matt

Joined: 2009-08-20
Posts: 40
Posted: Mon, 2009-09-28 15:52

Oddly it still shows "Add Album to Cart" on the front page but doesn't do anything when I click the link. It functions as normal in sub-albums. Strange.

 
bensgalery
bensgalery's picture

Joined: 2009-09-10
Posts: 17
Posted: Tue, 2009-10-06 16:47

Having the same problem running Carbon on Gallery 2.3, the 'Add Album to Cart' appears on the front page and in the sidebar. But nothing is added to the Cart when clicked, it opens up an empty Cart.
I am having kind of directory structure with sub-albums, which in turn again contain sub-albums without foto's in them. These first few 'child' albums don't contain photo's but only thumbs to the next album.
So here I need to remove "Add Album to Cart" because as long an album does not contain photo's nothing is being added to Cart.

To recognise albums which contain foto's and therefore require the 'Add Album To Cart' link, I tried the following code in album.tpl:
{if !$theme.children.canContainChildren == 1}
This results in an error for Unknown Index. The same happens trying {if !$theme.item.parentId == 0}. Is this wrong syntax?

Is there any other way to detect an album which does not have photo's, but several sub-albums?
If so then it could simply be applied in album.tpl near the top directly below the line:
{if $itemLink.moduleId == "cart"}
Something similar could then be applied for the sidebar.

Note: Above problem does occur for the 'Slideshow'. So here a solution appears to work assuring the link only appears where it can be executed. I assume this is taken care of in the Slideshow module further upstream adding Slideshow to $ItemLink.
I am not a big coder at all and have not been able to trace the code taking care of that. Else something similar could maybe used for the Cart module.

Ben

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 22888
Posted: Tue, 2009-10-06 23:18
Quote:
Is there any other way to detect an album which does not have photo's, but several sub-albums?

No not without check each child to verify that it is a album. Complex code, but I am sure a good php/smarty devloper could come up with something. It might have already been done, search the forums.

I don't use the cart module but don't understand whay you can't remove the permissions for the albums that are parents of albums that only contain sub-albums.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Another_Matt

Joined: 2009-08-20
Posts: 40
Posted: Thu, 2009-10-08 15:47

Ok, this fixed it for me.

Give Everyone [Add to Cart] permission on the root/main album. Make sure you check Apply to Sub-Albums.

Now, open the 1st layer of Sub-Albums one at a time and remove the Everyone [Add to Cart] permission but uncheck the Apply to Sub-Albums box.

This took the link off my main page albums which I use as basic categories but retained the link on the nested albums.

Thanks for your help in figuring this out Dave.

 
bensgalery
bensgalery's picture

Joined: 2009-09-10
Posts: 17
Posted: Fri, 2009-10-09 15:05
Quote:
don't understand why you can't remove the permissions for the albums that are parents of albums that only contain sub-albums.

Dave thanks a lot. My approach was way too complicated...
You solved it for me as well. For me no need to have it coded, only a few albums to be done manual the first time Another_Matt's way.