I've added a shopping cart in the theme I've customized, and it works great thanks to the help I've received here. I thought this issue was over, but when I try to use the search module and enter a search, it results in blank page. I've narrowed the problem down to the php code in the cart script for which calls the album title:
<?= $theme->parents[count($theme->parents)-1]->title; ?>
Even though everything works fine when the search is not used, it breaks the search page when the search tool is used. The next line of php works perfectly
<?=$theme->item()->title ?>.
I'm pretty sure I've misunderstood the help I was given before for this piece for the album title. I apologize for being so dense!
<head>
<script type="text/javascript">
<!--
function CalculateOrder(form)
if (document.myform.os0.value == "5x7")
{
document.myform.amount.value = 10.00;
document.myform.item_name.value = "<?= $theme->parents[count($theme->parents)-1]->title; ?>";
document.myform.item_number.value = "<?=$theme->item()->title ?>";
}
}
-->
</script>
</head>
Posts: 27300
On a search results page there is no item title.
check an object exists before trying to use it:
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 24
Thank you! That fixed part of it. Now when I search, it will open the search results page.
But, when clicking on a single image thumbnail on the search results page, it opens a blank page, even though the URL in the address bar is correct for that image, which doesn't seem possible. How can a URL be correct but not open up? But if I click on a thumbnail for an album in the search results page, the page for that album opens up just fine.
I'm still missing something for getting the individual image thumbnails to open up the photo page for that image from the search results page.
Posts: 27300
Don't know why. is there more code than you posted above like on a photo page?
A url to see the behavior might help.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 24
Okay, here's the link: [url=]My Gallery[/url]
If you search for "beach", it brings up 2 images. An individual image tagged as "beach", and the album which has the tag "beach". The album thumbnail works, the individual image opens a blank page.
Edited to add: I tried swapping out the default "wind" theme photo.html.php page with what I have, and get the same thing. So I don't think the main photo page is the problem. But when I remove this piece of code calling for the album name, it works.
<?= $theme->parents[count($theme->parents)-1]->title; ?>
Posts: 24
In case I'm not making sense anymore, here's the js and php I currently have in the head of page.html.php
<?
if(isset($theme->item()->title)) {
?>
<script type="text/javascript">
<!--
function CalculateOrder(form)
if (document.myform.os0.value == "5x7")
{
document.myform.amount.value = 10.00;
document.myform.item_name.value = "<?= $theme->parents[count($theme->parents)-1]->title; ?>";
document.myform.item_number.value = "<?=$theme->item()->title ?>";
}
}
-->
</script>
<? } ?>
And it's the <?= $theme->parents[count($theme->parents)-1]->title; ?> that is causing the problem, because when I remove it, the search results page works fine and everything opens properly.
Posts: 27300
Do you need this code on the search results page?
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 24
No, it only needs to be on the photo page, but it needs to be in the head section. Since it now works so well without the album title having that other piece of code for checking the object exists you gave me, I'm thinking I might be able to live without this other piece and just make sure my filenames have enough description in them. But the album title would be nice. Thank you for your help
Posts: 27300
Dave
____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 24
So do I still put it on the page.html.php? That's the only way I know to get it in the <head> section. Or does it not really need to be in the head? That's the only place I've used it (before I found gallery3). And I still need to have that other code you gave me wrapped around it, right? Totally confused here.
Posts: 27300
If you look at page.html.php it has similar code to only show content on the photo page ( that will include movies ).
There is some arguments that JS should go in the head and some should go in the footer. I guess it depends what it does. It could very well work inline so you could just add it to photo.html.php and see if it works.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 24
That worked for getting it to be only on the photo page, which works slick. But the blank page when clicking on the individual image thumbnail still happens.
Is this code:
<?= $theme->parents[count($theme->parents)-1]->title; ?>
that I have in my js the only format that will work to call the album title for that page?
Posts: 27300
I bet it works on sub albums?
Perhaps there is some info on this page http://gallery.menalto.com/node/109777 that might help.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 24
Thank you for your help Dave. I think I'm going to forget about the album name for now, because the filename works great and all the features are running smoothly, and I've decided I can live without the album name in the cart. I've read that thread you linked to several times, and I don't think this issue is worth the problems I'd be wading through and bugging you guys on here to help me with. You actually did help me on a much bigger thing when you told me how to make the code be only on the photo page, which was an ah-ha moment for me and I was finally able to put the shopping cart buttons in the sidebar for only the photo page, which is where I wanted them all along and thought was not possible. Made my day! I'm very happy with my completed gallery theme I've spent a crazy amount of time customizing, but it's been worth it. The help I've got here from you and Suprsidr have been excellent and I appreciate your patience
Posts: 1857
@Dreamer07: I'm a bit late here, and I'm not sure I understand the issue you're having, but I'd use something like this to get the name of the parent album from a photo page:
<? $xxpi=$theme->item()->parent_id; $xxpt=ORM::factory("item")->where("id", "=", $xxpi)->find(); echo $xxpt->title; ?>
Posts: 24
OMG! Tempg.... that works perfectly! Thank you!!!!!!!!
Posts: 1857
Glad it works for you! My code tends to be a bit "ugly," so you might want to change the variable names, etc. Using a lot of ORMs may eventually reduce performance a tad, but it will likely be marginal.
I'm still not 100% sure what the initial issue was, but if it's a problem with the basket module, you may want to recommend that the sum of the changes you made (or some variant thereof) be incorporated in an updated version of the module to help anyone else that runs into this issue.
Posts: 20
Hello,
I had a similar problem:
how to know a photo to which album belongs to.
Thanks to tempg I've added the to file theme page.html.php the following line
now it works !
It would be great to include this feature in Gallery3 core module info, or in another module, in order to have "to which album a photo belongs to" displayed on sidebar metadata.
Thanks,
DiegoS