Jump to content

Question(I think about arrays)


Unholy Prayer

Recommended Posts

It's an associateive array.  In java they inherit from the java.util.Dictionary class which is kind of a good way to think about them.  You have a key (think word) and a value think (definition).  This allows you you to do things like this:

 

<?php
$dictionary = array('bird' => 'Something that flies', 'dog' => 'something that barks');
echo $dictionary['dog'];
// prints: something that barks.
?>

 

Best,

 

Patrick

Ok, So how do I get something like {SITE_NAME} to display a string that gets the site name from a database?  If my code is

 

$settings = mysql_query("select * from ubs_settings where id=1");

 

while($s=mysql_fetch_array($settings))

{

 

 

  $sitename=$s["sitename"];

  $slogan=$s["slogan"];

 

}

 

how would I make {SITE_NAME} to display $sitename?

 

From my understanding writing MODs for phpbb, you have to have the tpl files included, using a function.  I wrote a mod that will display the user's theme next to their post in viewtopic.php, I added this to the associative array:

 

'POSTER_THEME' => $poster_style,

 

Then, in the tpl file, I added this where I wanted the theme name to appear:

 

{postrow.POSTER_THEME}

 

postrow was the name of the array.  I don't know anything about how to associate the template file and the associative array, I'm sure other people here do though.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.