Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 26 Oct 2018, 11:19
TransAmDan TransAmDan is offline
 
Join Date: Nov 2009
Accessing Database Value from a Template.

I want to access a database value from a VB template. The template is shown below. I have a new field in the 'attachment' table, called 'external_source' by default this will be zero, but if it is a 1, I want to produce different HTML code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Looking inside album.php I have modified the call to the database to include this field too.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So now $pictures contains the information from that database query.

Each individual pictures is fetched from
while ($picture = $db->fetch_array($pictures))

So in the template code I would expect pictures.external_source to contain the data from the database. Something isn't working right.

Is there some other process it goes through to pass data from album.php to the 'album_picturebit' template?
Reply With Quote
  #2  
Old 29 Oct 2018, 13:18
x iJailBreak x's Avatar
x iJailBreak x x iJailBreak x is offline
 
Join Date: Jan 2011
Originally Posted by TransAmDan View Post
I want to access a database value from a VB template. The template is shown below. I have a new field in the 'attachment' table, called 'external_source' by default this will be zero, but if it is a 1, I want to produce different HTML code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Looking inside album.php I have modified the call to the database to include this field too.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So now $pictures contains the information from that database query.

Each individual pictures is fetched from
while ($picture = $db->fetch_array($pictures))

So in the template code I would expect pictures.external_source to contain the data from the database. Something isn't working right.

Is there some other process it goes through to pass data from album.php to the 'album_picturebit' template?
If you do var_dump($pictures), what is the output?

Also, as a rule of thumb, it's best not to modify the core files - you should be able to utilize $hook_query_fields with the nearest hook to avoid making core changes to the code. Making core changes to the vB codebase is inadvisable as it can make it more difficult to upgrade, and usually means after upgrading the same changes need to be carried out again.
__________________
Professional web developer & sysadmin. Former bad man.
Reply With Quote
  #3  
Old 29 Oct 2018, 14:20
TransAmDan TransAmDan is offline
 
Join Date: Nov 2009
Thanks for the response, much appreciated.

Where would i put the var_dump? in the Template? I have tried a few different formats, but either get an error or no output.

{vb:raw var_dump($pictures)}

{vb:var_dump($pictures)}
Reply With Quote
  #4  
Old 02 Nov 2018, 23:01
x iJailBreak x's Avatar
x iJailBreak x x iJailBreak x is offline
 
Join Date: Jan 2011
Originally Posted by TransAmDan View Post
Thanks for the response, much appreciated.

Where would i put the var_dump? in the Template? I have tried a few different formats, but either get an error or no output.

{vb:raw var_dump($pictures)}

{vb:var_dump($pictures)}
Put it in album.php just after you run the query associated with $pictures.

Might also be worth putting exit after it too, so the var_dump is the only output.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I assume you are testing this on a different environment than live?
__________________
Professional web developer & sysadmin. Former bad man.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 07:00.

Layout Options | Width: Wide Color: