Announcement

Collapse
No announcement yet.

Including multiple functions from same file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Including multiple functions from same file

    This all started when I wanted to create a single file to modify for Who's Online hacks. In includes/functions_online.php:

    PHP Code:
    // who's online for links library
    case 'links':
        
    $userinfo['action'] = 'Viewing Links Library';
        break; 
    ... to line ~670, then add:
    PHP Code:
    // who's online for links library
    case 'local_links.php':
        
    $userinfo['activity'] = 'links';
        break; 
    ... to line ~1275. Then whenever I install something else I keep opening that same file and adding more stuff. An obvious recourse would be to just create two more corresponding files then include them like:
    PHP Code:
    <?
    // functions_online.php
    // 669 lines of beginning code
    include ("online_hacks01.php");
    // 606 more lines of code
    include ("online_hacks02.php");
    // 240 final lines of code
    ?>
    ... while online_hacks[01/02].php contain what's shown above, and you'd never have to open up functions_online.php again. Whenever you hacked in something else that needed "Who's Online" you just add code to online_hacks[01/02].php.

    What I'd really like to do instead is include only one file that assigns a function or var to each section of code, and nothing seems to work. Any ideas? I'm not all that great with functions, although this seems to be the wisest option.

    I asked about this at vb.org and naturally the only feedback so far is there is already a hack that does this. Fine, but I'm still in the dark about how to use functions to write stuff into a page in multiple places using one included file. This would come in handy in all kinds of scenarios (not just VB).

    Any help is appreciated.
    "I can't seem to bring myself to say, 'Well, I guess I'll be toddling along.'
    It isn't that I can't toddle. It's that I can't guess I'll toddle."

    --Robert Benchley (1889-1945)

  • #2
    Unfortunately since this involves custom coding you will need to continue asking at vbulletin.org.
    Steve Machol, former vBulletin Customer Support Manager (and NOT retired!)
    Change CKEditor Colors to Match Style (for 4.1.4 and above)

    Steve Machol Photography


    Mankind is the only creature smart enough to know its own history, and dumb enough to ignore it.


    Comment


    • #3
      Originally posted by welo
      Fine, but I'm still in the dark about how to use functions to write stuff into a page in multiple places using one included file. This would come in handy in all kinds of scenarios (not just VB).
      This is a general PHP question. I already installed the Who's Online hack available at vb.org. I still want to know how to do this.
      "I can't seem to bring myself to say, 'Well, I guess I'll be toddling along.'
      It isn't that I can't toddle. It's that I can't guess I'll toddle."

      --Robert Benchley (1889-1945)

      Comment

      Loading...
      Working...
      X