How to create custom variables line $board_config?

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
Andy D. Hajime
Registered User
Posts: 70
Joined: Fri May 13, 2005 6:03 am
Location: Neo Arcadia

How to create custom variables line $board_config?

Post by Andy D. Hajime » Fri Mar 21, 2008 11:58 am

i want to create a custom variables like $board_config and $userdata. I tried looking around the source but it leads down to common.php. Still, have no idea on how to make my own custom variables.

Anyone can help on this? or is there a guidelines somewhere which I can refer to?
Most appreaciated. ;)
What is phpBB eNcore?
blog entry #001: phpBB eNcore - DSDexigns finest phpBB pre mods

User avatar
stickerboy
Former Team Member
Posts: 7349
Joined: Mon Mar 29, 2004 2:27 pm
Location: Airdrie, UK (127.0.0.1)
Name: Kenny Cameron
Contact:

Re: How to create custom variables line $board_config?

Post by stickerboy » Fri Mar 21, 2008 12:05 pm

Your post would be better suited in MOD Writers, so I'll move it there for you :)
Please note that General Discussion is not for support of any kind - please read the forum descriptions in future before posting.


kenny.
I'm a web-designing code-decrypting tech-support musician
|| Twitter || Flickr || phpBB Snippets ||
Formerly known as cherokee red

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51876
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: How to create custom variables line $board_config?

Post by Brf » Fri Mar 21, 2008 12:12 pm

Do you know anything about programming at all?

You create variables on the fly:

Code: Select all

$my_new_variable='Some value';
Now I have a new variable....

Andy D. Hajime
Registered User
Posts: 70
Joined: Fri May 13, 2005 6:03 am
Location: Neo Arcadia

Re: How to create custom variables line $board_config?

Post by Andy D. Hajime » Fri Mar 21, 2008 12:35 pm

cherokee red wrote:Your post would be better suited in MOD Writers, so I'll move it there for you :)
Please note that General Discussion is not for support of any kind - please read the forum descriptions in future before posting.
kenny.
thanks kenny. sorry bout the trouble.


Brf wrote:Do you know anything about programming at all?
You create variables on the fly:

Code: Select all

$my_new_variable='Some value';
Now I have a new variable....
yes i know that. That is the very basic since echo.
Anyway, let me make out a little clear on my question.

On phpbb, if we wrote " echo $board_config['sitename'] "... this will echoed out the value for row 'sitename' under phpbb_config table. I was refering to this.

For instance, I have a custom table called PHPBB_TESTING. I want to know how to query that row value just like how $board_config did, without having to write SELECT from TABLE_TESTING where bla bla bla over and over again.

I hopes this is cleared enough. ;)
What is phpBB eNcore?
blog entry #001: phpBB eNcore - DSDexigns finest phpBB pre mods

User avatar
JRSweets
Registered User
Posts: 2047
Joined: Wed Apr 14, 2004 8:37 pm
Location: Massachusetts

Re: How to create custom variables line $board_config?

Post by JRSweets » Fri Mar 21, 2008 1:33 pm

Andy D. Hajime wrote:
cherokee red wrote:Your post would be better suited in MOD Writers, so I'll move it there for you :)
Please note that General Discussion is not for support of any kind - please read the forum descriptions in future before posting.
kenny.
thanks kenny. sorry bout the trouble.


Brf wrote:Do you know anything about programming at all?
You create variables on the fly:

Code: Select all

$my_new_variable='Some value';
Now I have a new variable....
yes i know that. That is the very basic since echo.
Anyway, let me make out a little clear on my question.

On phpbb, if we wrote " echo $board_config['sitename'] "... this will echoed out the value for row 'sitename' under phpbb_config table. I was refering to this.

For instance, I have a custom table called PHPBB_TESTING. I want to know how to query that row value just like how $board_config did, without having to write SELECT from TABLE_TESTING where bla bla bla over and over again.

I hopes this is cleared enough. ;)
You would want to add a function to cache.php similar to the function obtain_config()

Then in common.php you would have something like this:

Code: Select all

// Grab global variables, re-cache if necessary
$config = $cache->obtain_config();
$my_config = $cache->obtain_my_config(); 

Andy D. Hajime
Registered User
Posts: 70
Joined: Fri May 13, 2005 6:03 am
Location: Neo Arcadia

Re: How to create custom variables line $board_config?

Post by Andy D. Hajime » Sat Mar 22, 2008 7:09 am

Cache.php? Where?

erm... kenny? u still there? this was suppose to be for phpbb2... not 3. the post is being moved from a wrong section into another wrong section.
What is phpBB eNcore?
blog entry #001: phpBB eNcore - DSDexigns finest phpBB pre mods

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25462
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: How to create custom variables line $board_config?

Post by Paul » Sat Mar 22, 2008 9:36 am

Moved to 2.0.x MOD writers
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

User avatar
T0ny
Registered User
Posts: 1383
Joined: Sun Jan 29, 2006 8:42 pm
Location: Lancashire
Name: Tony

Re: How to create custom variables line $board_config?

Post by T0ny » Sat Mar 22, 2008 10:06 am

Andy D. Hajime wrote: For instance, I have a custom table called PHPBB_TESTING. I want to know how to query that row value just like how $board_config did, without having to write SELECT from TABLE_TESTING where bla bla bla over and over again.
This is the code (from common.php) that creates the $board_config[] array

Code: Select all

$board_config = array();

$sql = "SELECT *
	FROM " . CONFIG_TABLE;

if( !($result = $db->sql_query($sql)) )
{
	message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql);
}

while ( $row = $db->sql_fetchrow($result) )
{
	$board_config[$row['config_name']] = $row['config_value'];
}
Just replace CONFIG_TABLE with your table name constant and change $board_config to whatever array name you want to use. Also you'll need to change 'config_name' & 'config_value' to match the actual column names in you table.

Andy D. Hajime
Registered User
Posts: 70
Joined: Fri May 13, 2005 6:03 am
Location: Neo Arcadia

Re: How to create custom variables line $board_config?

Post by Andy D. Hajime » Sat Mar 22, 2008 10:11 am

T0ny wrote:
Andy D. Hajime wrote: For instance, I have a custom table called PHPBB_TESTING. I want to know how to query that row value just like how $board_config did, without having to write SELECT from TABLE_TESTING where bla bla bla over and over again.
This is the code (from common.php) that creates the $board_config[] array

Code: Select all

$board_config = array();

$sql = "SELECT *
	FROM " . CONFIG_TABLE;

if( !($result = $db->sql_query($sql)) )
{
	message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql);
}

while ( $row = $db->sql_fetchrow($result) )
{
	$board_config[$row['config_name']] = $row['config_value'];
}
Just replace CONFIG_TABLE with your table name constant and change $board_config to whatever array name you want to use. Also you'll need to change 'config_name' & 'config_value' to match the actual column names in you table.

Understood.
Thanks for the help!
What is phpBB eNcore?
blog entry #001: phpBB eNcore - DSDexigns finest phpBB pre mods

Post Reply

Return to “[2.0.x] MOD Writers Discussion”