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
Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
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

Joined: Aug 2007
Posts: 5
Lurker
Lurker
Offline
Joined: Aug 2007
Posts: 5
Yep... everything is easy 10 seconds after you figure it out wink Thanks much!


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
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
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-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)