Help needed adding PHP in javascript

Dreamer07

Joined: 2012-12-03
Posts: 24
Posted: Mon, 2012-12-03 04:07

Hello, I am trying to use a part of a shopping cart code in a Gallery3 theme I am customizing. My problem is with inserting the image filename and the gallery title between the " ". When viewing the source code of the generated page, it is blank between the " ". The file this code is on is the "page.html.php" in the "theme/views" folder, and this particular snippet of code is located in the <head> section.

I've been working on this for several hours now and nothing seems to work. I dont' know what to try next. I know it has something to do with php being ignored in the script type= text/javascript, but what I've found through google searches hasn't solved the problem. I don't understand javascript, but could that be a solution for calling the gallery name and filename?

Does anyone have any idea on how I can get this to work???

<script type="text/javascript">

<!--
function CalculateOrder(form)
{

if (document.myform.os0.value == "5x7")
{
document.myform.amount.value = 10.00;
document.myform.item_name.value = "<?= $page_title ?>";
document.myform.item_number.value = "<?= $item->title) ?>";
}

}
-->
</script>

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2012-12-03 05:58

$theme->item()->title should work if you are on a page that is a item. Not a tag page or album page.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
Dreamer07

Joined: 2012-12-03
Posts: 24
Posted: Mon, 2012-12-03 14:50

Thank you so much Dave!!! The $theme->item()->title worked for the filename! But I'm still having trouble getting the page or album title to work.

 
Dreamer07

Joined: 2012-12-03
Posts: 24
Posted: Tue, 2012-12-04 05:55

Bump... still trying to add the album title, but can't get it to work. The new code for the filename works perfect! The code for the line (as pasted above):

document.myform.item_name.value = "<?= $page_title ?>";

is not working. I tried the same format as the filename Dave gave, but I'm missing something big for the gallery name, because it breaks.

I do love this Gallery3 and think it will work perfect for my needs if I can get this shopping cart finished.

Thank you!

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2012-12-04 06:14

if you want to know everything that is available try <? print_r($theme) ?>

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
Dreamer07

Joined: 2012-12-03
Posts: 24
Posted: Tue, 2012-12-04 06:28

I'm just needing these two lines. Had some great help getting the one, just need the other thanks ;)

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2012-12-04 06:37

if you had tried my example you would have seen the page_title is a property of $theme
as in $theme->page_title and there are a ton more properties and methods you could derive if you had just taken my advice.

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
Dreamer07

Joined: 2012-12-03
Posts: 24
Posted: Tue, 2012-12-04 06:52

Sorry if you were trying to help. I did try it and got a ton of code that for me would be like finding a needle in haystack, and I don't know what I'm looking for because everything I've found that I thought would work, has not.

I do know that this:
document.myform.item_name.value = "<?=$theme->page_title ?>";

does not work.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2012-12-04 07:06

on an actual item page it should be $theme->item()->title else on an album page that would be part of the parent
like i outline here.

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
morganfeldon@gm...
morganfeldon@gmail.com's picture

Joined: 2009-06-22
Posts: 31
Posted: Tue, 2012-12-04 14:26
Quote:
Sorry if you were trying to help. I did try it and got a ton of code that for me would be like finding a needle in haystack, and I don't know what I'm looking for because everything I've found that I thought would work, has not.

print_r is the holy grail of figuring out what's in a variable. Yes, it is a lot of data to try to read and understand. If it helps, select the whole chunk of data and paste it into a Word doc. In your case, if you set the item/album name to something distinctive like "HELPMEOBIWAN" then you can search in the print_r() gobbledygook and find that text and then you know where to start.

 
Dreamer07

Joined: 2012-12-03
Posts: 24
Posted: Tue, 2012-12-04 14:26

Thank you Suprsidr!!! Your link had the info I needed :)