what is the caption PHP variable name?

firepol
firepol's picture

Joined: 2004-05-19
Posts: 99
Posted: Sun, 2005-03-06 20:50

Hi all,

I've "hacked" my G1 in order to use bbclone counter, and to display in the counter the correct pictures captions (as title of visited page) I needed to find the correct variables/functions names. Now I would like to do the same on G2.

E.g. in G1 the photo caption can be get with this function:editCaption($gallery->album,$index)

and the album name with this variable:$gallery->album->fields["title"]

Coming back to G2: at the end of main.php I've already added this code:

define("_BBC_PAGE_NAME","$pagename"); 
virtual("bbclone.php"); 

I need now some code in order to get the correct $pagename contents.

IF it's an album: I want $pagename to be the album title.
IF it's a photo: I want $pagename to be the photo caption.

Probably I'd like to make more hacks/customizations, and I'd like to know the most important variable names, is there a list somewhere?

At least the most popular variables: filename, caption, summary, descrption, creation date etc.

Thanks for letting me know.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2005-03-08 07:44

Unfortunately, there's no master list somewhere. One of the easiest ways to figure out variable names is to enable buffered debug mode in config.php, then load the page. You'll get a Smarty popup that contains all the data passed to the template. You can then search for the bit that you need and figure out the right variable name from that...

 
firepol
firepol's picture

Joined: 2004-05-19
Posts: 99
Posted: Tue, 2005-03-08 21:17

Thanks bharat, i got it... partially...

I guess you wanted to teach me something, giving me the right direction to understand myself what I needed to get...

but unluckily I'm not enough experienced in PHP and Smarty to do a simple thing like an echo line with a variable content posted there.
Maybe because that smarty functions are not that easy to udnerstand and the variables can't be easily used outside a template file?

I did as you told and saw the buffered debug popup with all variables shown.

I understood that there are several arrays, containing the same data:

$CommentItemDetails contains 5 arrays: the one that i need is called: item. inside item there are 23 variables such e.g. (i oly report a few of them):

pathComponent => DSCN0001.JPG
  description => empty
  keywords => empty
  ownerId => 5
  summary => empty
  title => DSCN0001

now, i see that the item array can be found also inside the $ShowItem and $layout array (redundancy of variables?).

Ok, here is what I tried to add at the end of the main.php file:

echo "ciao<br>";

global $CommentItemDetails, $ShowItem, $layout;

echo $CommentItemDetails[item]["title"];
echo $ShowItem->item->title;
echo $layout->item->title;

the only thing that I get at the end of the page is my ciao. Nothing else.
As you can see I tried several combinations, referring to http://www.php.net/manual/en/language.types.array.php

Can you enlighten me, please? I have no idea how to proceed, instead of trying to hack it all the night I guess it's more intelligent to ask to an experienced developer ;) Just give me one or two examples and I guess that then I'll be able to "extract" all the variable values in g2 and even do a "master list" as it's missing ;)

Thanks for letting me know

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-03-08 22:50

don't edit main.php.. put your tests in local *.tpl files. put the variable in { } and use . to separate each subitem.. example: {$layout.item.title}

 
firepol
firepol's picture

Joined: 2004-05-19
Posts: 99
Posted: Tue, 2005-03-08 23:00

i don't want to modify the template layout, i need to put the variable contents of the photo name (or album name) inside an external "page name" counter. so i need to hack the php file...

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Fri, 2005-03-11 04:28

It's better if you avoid hacking the PHP. Try modifying your local copy of global.tpl to include this:

{if isset($ShowItem)} 
{php} 
define("_BBC_PAGE_NAME", $this->_tpl_vars['ShowItem']['item']['title']); 
virtual("bbclone.php"); 
{/php} 
{/if} 

Put it somewhere sane in the HTML. That'll always use the title. You can look at the code that Smarty generates (find a file containing "global.tpl" under g2data/smarty and scan it for the code that you just added).

 
firepol
firepol's picture

Joined: 2004-05-19
Posts: 99
Posted: Fri, 2005-03-11 13:56

Thanks bharat, I did as you told (thanks also to you, mindless: at first I didn't understand your suggestion but after bharat showed me the code I clearly understood what you meant ;) ) and I can get the variable names correctly.

The initial questin opened in this thread has been answered.

Anyway, I'm getting some weird problems implementing bbclone in G2, so I'll start a new fresh topic especially for bbclone in G2, you an check the new thread here: http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&p=124451#124451