php forum
php mysql forum
php mysql smarty
 
Topic Options
#315796 - 09/24/07 11:28 AM Passing variables to/fro includes, templates, etc.
tpro Offline
Lurker

Registered: 08/29/07
Posts: 3

   Passing variables to/fro includes, templates, etc. to Del.icio.us Add to del.icio.us
  Digg Passing variables to/fro includes, templates, etc. Digg it
This is a UBB code/template behavior specific question (I think) and I hope this is the right place to ask this.

Anyway, I was looking into tweaking some code to allow our users to hide "closed" topics (a.k.a. "Locked".) Some background is here: http://www.ubbcentral.com/forums/ubbthreads.php/ubb/showflat/Main/41549/Number/198017

I've got it where there is a check-box under Display Options at the bottom of the post list titled "Hide locked topics." It works where I can click this button, click Change, and the topic list reloads with the locked threads not displayed. But, the button state does not stay checked after each reload at this point. So, this brings me to my question.

How would I get the value that I pass in with this checkbox back in to set the state back to checked?

More detail here...

In postlist.tpl, I added a checkbox option as follows (this would be after the existing form elements):
Code:
<br />
Hide locked topics: <input type="checkbox" value="1" name="hidelocked" {if $hidelocked=="1"}CHECKED{/if} class="form-checkbox" />


The "if" isn't working, as I don't know how to get that hidelocked back in to this point.

The following changes are made in postlist.inc.php... after the "order" line, which should be around 41, I added the following:

Code:
"hidelocked" => array("hidelocked","both","int"),


On about line 63, which should be right after "// Define any necessary variables" line, I added the following:

Code:
$hidelockval = "";


Then after line 109 (after the variable declarations), add the following code:

Code:
	if (!$hidelocked) { $hidelocked = 0; }

	if ($hidelocked && ($_SESSION['myprefs']['hidelocked'] != $hidelocked)) {
			$_SESSION['myprefs']['hidelocked'] = $hidelocked;
	}

	//If we are hiding locked threads, add the query string
	if ($hidelocked == "1") {
		$hidelockval = "and t1.TOPIC_STATUS = 'O'";
	} 


Now, the myprefs stuff in there was "fishing" trying to see if that's how to share the values between the various components (includes, templates, etc.)

Then after around line 746 or so (all these numbers change as more is added, etc.), which should be "t1.TOPIC_IS_STICKY...", I added the following to expand the query to exclude the closed topics:

Code:
$hidelockval


So, I realize there are opportunities in the code (I've not used PHP much before, and don't know the framework I'm working in with the templates, etc.,) but I'm sure there is something easy I'm missing. After all, everything is easy 10 seconds after you figure it out.

Thanks much!

Top
#315799 - 09/24/07 12:40 PM Re: Passing variables to/fro includes, templates, [Re: tpro]
sirdude Offline
Enthusiast

Registered: 11/08/03
Posts: 439
Loc: SoCal
you really need to just inform smarty of the variable..

look towards the bottom and find

Code:
$smarty_data = array(
	"catrow" => array(0=>array('CatId'=>$Board)),
..


add a row that pass your $hidelocked from the .inc.php to the tpl.

like so (add this line):
Code:
"hidelocked" => $hidelocked,


now smarty (the .tpl) knows about the value of $hidelocked from the script..

good luck,
SD

oh, and there's also a file in your /scripts directory called sample.inc.php that is commented and will explain a lot of what isn't documented anywhere. well worth a read wink
_________________________

A taxpayer voting for Obama is like a chicken voting for Colonel Sanders.

Top
#315803 - 09/24/07 04:28 PM Re: Passing variables to/fro includes, templates, [Re: sirdude]
tpro Offline
Lurker

Registered: 08/29/07
Posts: 3
Yep... everything is easy 10 seconds after you figure it out wink Thanks much!

Top


Top Posters Last 30 Days
AllenAyres 12
Gizmo 10
S7ARBVCK 2
blaaskaak 2
Cambridge 1
Murphdog 1
MattUK 1
Who's Online
1 Registered (blaaskaak), 31 Guests and 8 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
[7.3.1] add search to showmembers page
by blaaskaak
22 minutes 13 seconds ago
BeyondCompare v3.00
by blaaskaak
09/05/08 02:46 PM
Noob - need help, or a reality check!
by Gizmo
09/04/08 03:21 AM
Here I am! Rock me like a Hurricane!
by AllenAyres
09/02/08 03:05 PM
[7.x] Generic Page Outside of forum directory
by Gizmo
08/30/08 05:43 PM
Team UBBDev Rides Again!
by Gizmo
08/28/08 11:45 PM
Multiple Identity Detector
by MattUK
08/28/08 04:10 PM
New Mods
[7.3.1] add search to showmembers page
by blaaskaak
22 minutes 13 seconds ago
Installing FlashChat with 7.3
by Paug
08/23/08 12:14 AM
[7.3.x] ubb.links
by AllenAyres
06/20/08 11:50 PM
[7.2.1] - Naked shoutbox
by sirdude
08/17/07 10:36 PM
[7.x] Generic Page Outside of forum directory
by
01/14/07 10:58 PM
Newest Members
veedubb8, twentyseven, Claus1, welcomeback1, Paug
13327 Registered Users

 

 

 
fusionbb message board php hacks