vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Fetching different templaets w/ same eval() statement??? (https://vborg.vbsupport.ru/showthread.php?t=181300)

Antivirus 06-02-2008 04:53 PM

Fetching different templaets w/ same eval() statement???
 
I have the following 3 different eval statements based upon a conditional...

PHP Code:

foreach ($sc_gblockinfo AS $sc_gblock)
{
    if (
$sc_gblock['pos'] == 'top')
    {
        eval(
'$sc_gblockbits_top .= "' fetch_template('sc_gblock_edit_bit') . '";');
    }
    else if (
$sc_gblock['pos'] == 'left')
    {
        eval(
'$sc_gblockbits_left .= "' fetch_template('sc_gblock_edit_bit') . '";');
    }
    else if (
$sc_gblock['pos'] == 'right')
    {
        eval(
'$sc_gblockbits_right .= "' fetch_template('sc_gblock_edit_bit') . '";');
    }



however i know it could be written more efficiently, and I have tried the following, along with different variations, however I just can't seem to figure it out...
PHP Code:

foreach ($sc_gblockinfo AS $sc_gblock)
{
    eval(
'$sc_gblockbits_' $sc_gblock['pos'] . ' .= "' fetch_template('sc_gblock_edit_bit') . '";');


Within the loop, $sc_gblock['pos'] can be one of three possibilities, 'top', 'left', or 'right'... I'm basically just looking for a more compact way of writing the first example above.

Anyone got an idea of how to do this correctly?

Opserty 06-02-2008 04:58 PM

Doesn't it work? It seems correct to me, what errors if any do you receive?

Antivirus 06-02-2008 05:14 PM

jeez, im in tard mode today - i was saving the plugin to the wrong hook. It is working, I was pulling my hair ou earlier thinking it was the code, lol - thanks Opserty :)

Opserty 06-02-2008 09:10 PM

Haha, no problem ;)


All times are GMT. The time now is 05:16 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01020 seconds
  • Memory Usage 1,719KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete