Customizing SMF > SMF Coding Discussion

Where to put persistent code?

(1/2) > >>

BinkyM:
Hi, SMF peeps:

I have a script I'd like to be available nearly all the time. Where's a good place to put it? I'm thinking in the file wherever the footer is kept. Is that a good place? I did some grepping of my SMF files and it appears that the footer happens in a file called index.template.php in my theme directory. Is that a good place to put a script I'd like to be persistent?

(I'm an SMF neophyte, so please excuse me if I come across like a boob.)

Thanks for a tip,

Binky

4Kstore:
Hi binkyM, if the code is a function you can put in load.php o subs.php (in sources file), You can call the function from anywhere
If the code is a script you can add in index.template.php in the header section.

Maybe you can add more information and i can help better..
Bye!

MrPhil:
Please clarify what this script is, and how you want it 'available'. Is it a standalone page or shell script, or is it code to be stuck inside some part of SMF (additional function on the page)? How are you thinking of invoking it -- as part of SMF or something completely on its own? If it's standalone, just give it a nonguessable name and stick it in your site root. If it's meant to interact with SMF in some way, or be embedded in it, we'll need to know a lot more about it.

Labradoodle-360:
Yeah, we need to know more about "this script". SMF uses an MVC (Model-View-Controller) meaning source is separated from template.

BinkyM:
MrPhil and Labradoodle:

One script is an Amazon code snippet such that I can make reference to an Amazon product any time I want to. The other is VGlink code that links to a product when it finds a word in a post that's linkable and I can make some scratch if a user clicks the link).

Is 4kStore right that  load.php and subs.php are good places to stick that code? They look good at a cursory glance.

Binky

Navigation

[0] Message Index

[#] Next page

Go to full version