Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Aug 2007
Posts: 5
Lurker
Lurker
Offline
Joined: Aug 2007
Posts: 5
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!

Sponsored Links
Entire Thread
Subject Posted By Posted
Passing variables to/fro includes, templates, etc. tpro 09/24/2007 6:28 PM
Re: Passing variables to/fro includes, templates, sirdude 09/24/2007 7:40 PM
Re: Passing variables to/fro includes, templates, tpro 09/24/2007 11:28 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Nettomo
Nettomo
Germany, Bremen
Posts: 417
Joined: November 2001
Forum Statistics
Forums63
Topics37,575
Posts293,930
Members13,823
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)