Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
Using PHPINCLUDE_START. (Last Lesson - #7 - Added 12-16-4)
Michael Morris
Join Date: Nov 2003
Posts: 774

Employee of Digital Media Graphix of Knoxville TN, currently developing a new framework / CMS

Knoxville TN
by Michael Morris Michael Morris is offline 03 Nov 2004

This is a tutorial on the use of the PHPINCLUDE_START template. In the process of writing an 800+ line monster into the boards I help administrate I learned a few things about this template I'd like to share. In this tutorial you'll be applying several hacks as an excersize, though some you may wish to keep as an enduring part of your boards.

This tutorial assumes you know next to nothing about PHP, but it does assume you know a little about XML/HTML.

The examples used in this tutorial are based upon a clean install of vbulletin. If you've made changes you'll need to adjust appropriately.

Ready to begin? GREAT!

Some basics
If you've done any editting of your forum's styleset you've seen the PHPINCLUDE_START template and it's brother the PHPINCLUDE_END template (which is touched upon occassionally but not covered exhaustively here). These templates provide a means for you to inject you're own php code into vbulletin WITHOUT voiding your Jelsoft User Support eligability. PHPINCLUDE_START executes before any other templates are parsed, and PHPINCLUDE_END executes after all other templates are parsed.

By the time vbulletin reaches the PHPINCLUDE_START template it has done the following
  1. Loaded the user's information
  2. Loaded the forum information
  3. Cached all phrases due for use on the page.
  4. Loaded the CSS and the style variables for the current style.
  5. Cached (but not parsed) all templates due to be called on the page.
  6. Defined all common functions used in vbulletin.

Hence you can at this point reset any and all of this information, but be warned that you can cause interesting things to happen.

$phpinclude_output
PHPINCLUDE_START is parsed under an object buffering mask. This means that statements that normally print things to the screen of the browser (echo, print statements) don't affect the browser. Instead the results of these statements is put into the $phpinclude_output variable (NOT $_phpinclude_output as listed in the header templates of vb 3.0.3. This is one of the surviving bugs in vb3).

By default $phpinclude_output is contained within your header template (Again, under the eronous $_phpinclude_output). But since we're not planning to just include an html header we need to do something else with it. Note that you don't want to get rid of it entirely - if you're script has a non-fatal error the results of the error message go into $phpinclude_output and you'll need that for debugging.

So let's move it somewhere useful - the footer.

Open your footer template and append the following code to the very end.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now if you haven't already go to your header template, find $_phpinclude_output and remove it. The above code makes the $phpinclude_output data display at the end of your pages where it's unlikely to affect the layout. The conditional insures that only administrators get to see the output.

Why would we want to limit this to admins? Well, for one, do we really want users seeing error statements? Not really. For another it allows us to use echo and print statements to debug our scripts.

Let's test this code. Clear out your PHPINCLUDE_START template's entire code (if you're on a fresh install) and type in the following


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now reload your home page. At the bottom you should see "Hello World." Log out. The message should dissappear. Log back in. Now let's do something useful. Clear out the PHPINCLUDE_START template again and put this in.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

At the bottom of you're page you'll see something like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And so on. All that stuff is the contents of $bbuserinfo. $bbuserinfo is an array which means it's a multipart variable. The stuff in [] are the elements to the array. The stuff to the right of the => are the values each element currently contains. Hence $bbuserinfo['userid'] contains the value of "1" (This output is from my test server where I'm the primary and only user).

That concludes today's lesson. Tomorrow I'll append one of my hacks, the System announcement system, and go over it in detail to explain how and why it works.

Lesson Two - An Announcment System in templates - Part 1

Today we're going to begin to build an announcment system and explore a couple of the functions unique to vbulletin in the process. The hack by itself is here, and over the course of the next few lessons we will arrive at that code.

Before we start playing around with PHPINCLUDE_START template in depth though it's advisable to build a style specifically for your tests with it. This way you can iron the bugs out on your experiments without crashing vital you're boards (which is possible - Fatal errors in PHPINCLUDE_START can bring the whole thing down in a hurry).

Now, let's start our announcment system. The first part is defining output that will be displayed in the template. The system does this already for our echo and print statements by plugging them into the $phpinclude_output variable. That isn't the only variable we can use though. We can define any varaible we like and be able to post it into most templates. Templates that are used in functions, such as forumdisplay_nopost_level1, require a little creative cheating which will be discussed another day.

To be effective announcements need to be in a prominent place, and few templates are as prominently placed as the header. So at the very end of your header put the following in


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Clear out PHPINCLUDE_START and plug this in.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reload your page. "Hello World" should be displayed in place of the $announcement variable.

Rules for variables
PHP, like all other programming languages, uses variables extensively, and PHP also has a particular love of array variables with over 40 functions devoted to their manipulation. Unlike some languages like C++ you don't have to declare your variables at the start of your program, though it's good practice to do this. One reason is security

Security Warning: If you don't initialize a variable properly PHP might take it's value off of the browser line. For instance in the URL somewhere.php?file=lazy PHP will start the script with the variable $file already set to 'lazy.' Depending on that variable's role in your script the result of hackers putting variables on the browser line can range from annoying to catastrophic. Vbulletin initializes it's variables to guard against this threat and you should get in the habit of doing it as well in case you ever write PHP code intended to be ran outside of vbulletin.

Variables in php always start with $ and contain no spaces. A few variables are reserved - if you use a PHP context editor such as Dreamweaver you'll be alerted to this when the text changes color.

More info on variables can be found at www.php.net

Ok, back to our variable, $announcement. Let's set it to something more interesting than "Hello World"


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Note the . This is an append. You can do this multiple times so that you can get a feel for what the text is going to look like on the screen. Just make sure that only the final line has the ending ; character or you'll get a parse error.

Now while this is all interesting it isn't particularly useful. What can make things interesting is putting a conditional in - if.

Two faces of "IF"
The if statement is the the most common control structure across all programming languages. Even Commodore BASIC had if statements. These statements allow you to execute code according the a condition. Let's try a very basic conditional for our announcement which limits it to us.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Save and reload your page. You should see the first message if you are the founding member of your board. Now log out. You should see the other message.

Now, with a single ! we can turn this whole thing around. Putting ! at the start of a condition is the same as saying "NOT" Try this


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

You can do this within the templates as well, though the format is slightly different.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

But note that not all the possible conditionals are avaiable in templates.

Well, that's enough for today methinks. Next lesson will begin to cover some serious ground by actually setting announcement to a useful value.

Lesson Three - An Announcment System in templates - Part 2

Today we'll finish up our announcement system. With knowledge of conditionals we can build the thing entirely in the PHPINCLUDE_START template, but defining the variable on all those conditions can be painstaking and hard to edit. Wouldn't it be easier to put it all in a custom template? That way we can simply edit each of our announcements individually without worrying about affecting our code. This is also useful if you have a co-admin or a client that knows nothing about PHP and isn't willing to learn, yet they want to be able to type up announcements to be displayed in their header.

Well, yes it is easier, and possible, but we gotta go fetch.

The fetch_template and eval functions.
When you make a custom template you can't simply plug it into other templates. Indeed, the ability to define you're own templates wouldn't be terribly useful if you couldn't call them back. The fetch_template function accomplishes this.

The format of this function, by itself, is:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

We can assign a template to a variable by doing the following:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Try it and see. Create a custom template called announcment and save it, then put the above statement in and reload your page. Pretty cool eh? But something's not quite right. If you read through the vbulletin sourcecode you'll almost never see the above, but you will see this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

eval? What's that about. Well, try this. Open your announcement and plug in the following.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

You'll get back exactly, "Hello $bbuserinfo[username]." This brings us to our next function. eval is a PHP defined function (meaning it's always available in PHP whether you're using vbulletin or not) that evaluates a string. Eval pulls variables and template conditionals out of our templates and, well, "evaluates" them.

Now, time to build

Now that we understand the tools let's go ahead and build our announcement system. First let's pretty up our announcment in the header.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That frames the announcement in a table with the style definitions given for table borders in the current style - meaning it will look like a forum rules box.

Now we'll define six announcements, as follows
  1. A general announcement for all members, when necessary (like "Hey, I'll be shutting the boards down for awhile at a certain time, get you're post with done by then")
  2. An invitational announcement for guests, similar to the default one given on the forum home page but appearing instead on all pages.
  3. A message for users who need to complete their registration via email.
  4. A message for the moderators, supermoderators, and staff.
  5. A message for users who've never posted
  6. A message for users who've not posted in the last 14 days
  7. And a message for all other users.

The names for these custom templates should be, in the same order:
  1. announcement
  2. announcement_guest
  3. announcement_pending
  4. announcement_staff
  5. announcement_noposts
  6. announcement_noposts14days
  7. announcement_registered

Now, clear out the PHPINCLUDE_START template and plug in the following:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

All that stuff is commentary text. The computer ignores anything that follows a double backslash ("//"). It's useful for writing notes to ourselves about what the code is doing (or supposed to be doing). Lot's of commentary text makes the code easier for others to understand. It has next to no effect on performance, so use it and use it often.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

To review, the $is_member_of function checks to see if the user ($bbuserinfo)belongs to the usergroup stated.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Usergroups must be checked one at a time. If you use "is_member_of($bbuserinfo, '4, 5, 6') the function only returns users beloning to ALL THREE of those groups.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

TIMENOW is a defined constant that holds the Unix timestamp value of the current time. Vbulletin stores all dates and times by their Unix timestamps, which is simply the number of seconds that have passed since Midnight on January 1, 1970 in the Greenwich time zone (Trust me, it's a lot of seconds). 1209600 is 14 days worth of seconds.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And that's it. From here you should now have the knowledge necessary to create additional announcements and link them to your custom usergroups.

Next lesson we're going to start playing with user profile fields and using them to create user controls on the vbulletin display.


Lesson Four - Power to the People #1 - User Selectable Postbit

Start a thread on your boards about the layout and you'll a list of things folks don't like. Worse, often the thing one user detests will be something other users enjoy. Wouldn't it be nice if you could please everyone? Well, in vbulletin you can allow them to customize the layout to their tastes.

Layout customization requires use of the User profile fields and most of the time it requires one or more template edits. We'll start with a simple one - letting the users choose the postbit layout (Note: This hack was originally discovered by Boofo, one of our moderators).

As you know, vbulletin has two layout schemes - postbit (used over at www.vbulletin.com) and postbit_legacy (used here). The existing switch for these is in the vbulletin options panel. The setting is stored in $vboptions['legacypostbit']. If it's set to 1 (true) then we use it, otherwise we don't.

Since you probably want to keep the announcement system we'll slide our next bit of code in front of it (This is one of the reasons why we used the header to clearly mark the start). We'll give it a header too. But first we need to go to user profile fields and create a new one. Choose to create a Single Selection drop down menu with the options of "Default - Vb3 style" and "Classic - Vb2 style" Put it in the thread viewing options. Note the field # that vbulletin assigns to it and plug it in for X below where you see "fieldX"


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The way this query works is that first we check if a userid is present. If this isn't true we can go ahead and skip all the user settings because we're dealing with a guest.

Only then do we check for the field. Note the use of a new inbuilt function - strstr. strstr has the following format:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The $haystack is the string we're going to search, in the above example $bbuserinfo['fieldX']. The needle is the string we're looking for - 'Classic'. This allows you to create very long drop down menu options without having to quote them back in the phpinclude_start script - all you have to remember is the keyphrase.

Incidently, strstr is case sensitive. It has a brother, stristr, that is case insensitive.

This concludes this lesson. Next time we'll deal with some more template editting intensive features.


Lesson Five - Power to the People #2 - Bold / Not so Bold; Italics / Rather not

By default vbulletin displays New threads since the last visit in bold. Suppose a user doesn't want that. Well, we can do that. Another user would like his subscribed threads to be displayed in italics so they're easier to spot. We can do that too.

Open the threadbit template and search for this code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Replace it with this doozy of a chain conditional:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now, create two new user profile fields that are single selection radio buttons. The selections should be yes or no, and the questions should be whether the user wants new threads in bold and subscribed threads in italics.

Now let's open our PHPINCLUDE_START template. Since we want these items to be displayed by default we need to set their defaults, so at the very top


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now we'll nest in our two new options into the user options below. This should all go after the //Set Postbit conditional but before the $bbuserinfo conditional is closed.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Else statments aren't necessary here because there are only two possibilities and we've already set the alternate.

Homework!!

Now, it's time to apply what you've learned. As you're probably aware, when you move your mouse over a thread's cell you will get a preview. Create a switch like the ones above that turns the thread previews on or off.

Hint 1: The thread preview is in the thread bit template.

Hint 2: Specifically, it's here (Don't look if you want to hunt for it...)












Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

PM me if you need more help.

This concludes the basics of template based switches to control the user layout. In the next lesson we'll move onto something a bit more complex


Lesson Six - Power to the People #3 - My Links Dropdown System

Look around any boards and you're likely to note that some users use their sigs to display board related links to their favorite threads or outside sites. Some users also use their favorite boards as homepages. Wouldn't it be nice for these users if they could put some of their links in an easy find location

Say, the navbar dropdowns is a useful spot.

To begin this project create a user profile field that is multiple text lines and has a character limit of at least 2000. The user is then going to put links in this profile field using the standard url related tags - url, post, and thread.

Once you do that crack into your navbar and look for this code:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Immediately after add.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Next look for this code in the navbar


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Immediately above it insert the following code


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Now we go back into our phpinclude_start template and insert this code alongside the other user options we created in lesson 5


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

As before, you need to plug the correct user profile field # into the spot occupied by "field14" above.

As to what this code does, line by line:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

We need to use a function that isn't normally called by the time vbulletin parses the phpinclude_start library but resides in this function library. If we don't do this we'll get a fatal error - function not defined - on the next line. We use require_once in case the bbcode parse library has already been included - if it has there's no need to include it again.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This parses the code. $bbuserinfo['field14'] is the user's links. The 0, 0, 0, 1 are the parsing options: In order they are - HTML off, Smilies off, Automatically parse URL's off, bbcode On.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The parser puts breaks in on the carriage returns. We don't want these so we strip them back out.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

These place each url on their own table row so that the navbar dropdown displays correctly.


Lesson Seven - Navbar Games #1: Avatar in the Navbar

The navbar is one of the most powerful templates in vbulletin. It is quite literally the heart of you're poster's browsing of your boards. While it has a lot if information in it, you can certainly cram in some more.

Let's take a look at this template because the next several lessons are going to involve changes to it and it's useful to have a good understanding on how its built before cutting into it.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This script turns the screen gray on IE (uses Microsoft's proprietary browser commands so I'd be surprised to see it work elsewhere). It also launches the "Are you sure you want to log out?" button. We shouldn't need to mess with this, ever - but if you move the dropdowns elsewhere (say, into the header template) then you might want to move this with them.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This single break establishes the default distance between the navbar and the top of the page. Omitting this will cause the navbar to be at the exact top of the page and, presumably, right up against the header. There are times when you want this though, and I've omitted it quite often for the various Wizards of the Coast templates I built.



Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This starts the navbar proper. The first section that is the breadcrumbs...


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The one conditional above is concerns whether or not there exists and "navbits" Navbits always have a second line to indicate the current page, so they have an alternate formatting.

Note that you can trade all of the above with the table below to switch the order of the user information and the breadcrumbs on your page if you want.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This is checking to see if the current user has a userid (and if so, they aren't guest and the are logged in). If true we present the user a welcome block with their name et all.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

If false we present the login block below.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That's the first major part of the navbar. The second part is the drop down menus. They are split in two: One creates the buttons on the bar, and the second part has the drop down menus.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

There's the buttons


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

These breaks control the spacing between the navbar and the body of the page. Again, you can alter this if you want to change this spacing.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And there's the menus. Follow the commentary text (the stuff between the <!-- and --> marks.

Time to get down to business.

Ok, so much for the review, let's do something fun - put the logged in user's avatar into the navbar. This is useful on boards where a log of people use multiple user accounts - it lets them know who they are logged in at a glance (assuming the avatars are distinct).

This is actually pretty straightforward. First we fetch the user's avatar. In your PHPINCLUDE_START template plug in this code at the end.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

For those users that don't have avatars, you need to create a "noavatar.gif" image for them. If you already have one (say, from vba_cmps) then just make sure it's in the misc directory.

Now, going back to the navbar let's plug this in like so... Find this code in the navbar


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And add this code below:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Unless your forum uses small avatars, you'll probably want to modify the code some more to get the formatting to look nice, but the hard part is over at this point.

This concludes lesson 7. Expect to see more of these in the coming few days as I have more spare time now that the Christmas break has began.

Last edited by Michael Morris; 17 Dec 2004 at 01:41.. Reason: Lesson 7 Added
Views: 11028
Reply With Quote
Comments
  #2  
Old 05 Nov 2004, 11:53
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Real name: Michael Morris
Lesson 2 added to first post - applying bump.
Reply With Quote
  #3  
Old 07 Nov 2004, 06:40
Logikos Logikos is offline
 
Join Date: Jan 2003
Nice work MM, will come in handy for many users.
__________________
Full Time PHP Developer
Please feel free to contact me if you have any paid work to be done.
Reply With Quote
  #4  
Old 07 Nov 2004, 13:12
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Real name: Michael Morris
Thanks Live Wire. Just trying to help out others as othes have helped out me Day 3 added btw.
Reply With Quote
  #5  
Old 10 Nov 2004, 01:43
traderx's Avatar
traderx traderx is offline
 
Join Date: Jul 2003
wow... thanks alot MM... I a trying to learn the ins and out of PHP/VB. Though I haven't yet to play with your tutorial, will you be able to go over how to call template that have code in them (sorry if the above covers that will start now to use what you have writen) I have columns that I have added to the left and right I would like to learn to to put items in there (and maybe with conditions) from templates or file.

Once again thanks alot
Coll
Reply With Quote
  #6  
Old 12 Nov 2004, 14:36
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Real name: Michael Morris
Thanks for the kind words. I'm still learning myself - and writing this is sorta like doing written exam of sorts. I trust that if there are any errors the more experienced coders will point them out, though I'm going to some pains to make sure the examples are valid.

Lesson 4 added.
Reply With Quote
  #7  
Old 13 Nov 2004, 03:38
Gio~Logist's Avatar
Gio~Logist Gio~Logist is offline
 
Join Date: Jun 2004
Location: San Francisco
Real name: Giovanni Martinez
great work, i would love to mater php soon
__________________

ModernvB.com - vBulletin Mods & Services - ModernvB.com vBulletin 3 Mods - ModernvB.com vBulletin 4 Mods - Hire ModernvB
Full-Time vB Development - If you can think it, we can build it.
Reply With Quote
  #8  
Old 13 Nov 2004, 09:40
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Real name: Michael Morris
You can - just take it a little step at a time.

Lesson #5 added.
Reply With Quote
  #9  
Old 13 Nov 2004, 11:35
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Real name: Dean Clatworthy
One point, you're not caching the templates when you use phpinclude. It's always good to add it to the cache on the relevant php page
__________________
Dean Clatworthy - Web Developer/Designer
Reply With Quote
  #10  
Old 13 Nov 2004, 12:01
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Real name: Michael Morris
Good point Dean, but doing that constitutes a direct hack of the code and voids the Jelsoft user support plan.

That said, since phpinclude_start executes at the very start of any page load it's best to cache it's templates at the start of global.php. Here's how:

In your global.php file look for this code

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Directly after it add the following:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

That merges in the templates mentioned in Lesson 3. If you add more templates, simply add them to the list following the format given above - each item in ' ' marks and followed by a coma (if you miss a coma on the very last entry it doesn't matter).

EDIT: I don't do this on a fairly large board and it doesn't seem to slow the system down noticably - then again we have some very new equipment there. Dean's right - doing this will reduce the # of queries ran, but at a cost of voiding the support program - at least until you remove the hack.

Last edited by Michael Morris; 13 Nov 2004 at 12:03.
Reply With Quote
  #11  
Old 14 Dec 2004, 23:47
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Real name: Michael Morris
Lesson #6 added. Sorry for the long delay - been getting back into the swing of classes and also having trouble coming up with new ideas for lessons.
Reply With Quote
  #12  
Old 17 Dec 2004, 00:15
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Real name: Michael Morris
Bump - Lesson 7 added.
Reply With Quote
  #13  
Old 26 Dec 2004, 21:46
darnoldy darnoldy is offline
 
Join Date: Dec 2004
Michael-

Tried to apply your lesson on announcements but have not succeeded. Somewhere I'm missing something. Hope you can help!

1. created new templates:
newsflash_all
newsflash_guest
newsflash_noposts
newsflash_pending
newsflash_staff
newsflash_subexpiring

2. Added the following to phpinclude_start:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

3. Called the appropriate template by inserting:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

in the forum_home template.

it doesn't display the content of the newsflash template. What did I miss?

--DON

Last edited by darnoldy; 26 Dec 2004 at 21:52.
Reply With Quote
  #14  
Old 27 Dec 2004, 01:01
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Real name: Michael Morris
You don't have a default - so it could be working silently in the background.

I don't see anything straight off, but check things one line at a time. First check to make sure the insert to your forumhome template is working correctly. To do this put $newsflash in the template and then set it to a value straight out in the PHPINCLUDE_START template


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

If that works, put a value in your newsflash_all statement and check to make sure the eval statement syntax is correct.

(Note - if you have multiple styles it's important to put these templates into either one grand parent of all your styles or into each style individually - fetch template can't call up a template that doesn't exist in the current style).

If that works check your conditionals, one at a time, to insure they work.

If you have any other problems check with me.
Reply With Quote
  #15  
Old 27 Dec 2004, 04:33
darnoldy darnoldy is offline
 
Join Date: Dec 2004
Michael-
Originally Posted by Michael Morris
check your conditionals
okay, I found *where* its not working:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

The first statement will pass the contents of 'newsflash_all' properly.

The If statement tests false--with 'newsflash_all' as empty as I can make it.

I don't know enough php to know if this is a mal-formed statement, or something else.


--don
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 00:52.

Layout Options | Width: Wide Color: