Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Showing a selected value
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
Showing a selected value
I am working on a setup which shows the selected filter for one of my forums using XThreads. I have a working system, but it seems a bit clunky and I would like to know if there is an alternative method. I wanted to use this in another forum, but there are a lot of options.

In ths current forum I have one filterable field - fcat3

This is the code I am using for the dropdown and display:

HTML Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<table border="0" cellspacing="{$GLOBALS['theme']['borderwidth']}" cellpadding="{$GLOBALS['theme']['tablespace']}" style="clear: both;">

	<tr>
		<td class="trow1" align="center">
			<form action="forumdisplay.php" method="get">
				<select name="filtertf_fcat3">
					<option value="">Select a Category</option>
					<option value="">All</option>
					<option value="Plugin">Plugin</option>
					<option value="Modification">Modification</option>
					<option value="ProPortalBlock">Pro Portal Block</option>
				</select>

<input type="text" class="textbox" name="search" size="35" value="{$searchval}" /> {$gobutton}
				<input type="hidden" name="fid" value="{$fid}" />
				<input type="hidden" name="sortby" value="{$sortby}" />
				<input type="hidden" name="order" value="{$sortordernow}" />
				<input type="hidden" name="datecut" value="{$datecut}" />
			</form>
		</td>

<td class="trow1" align="center"> Your Current Filters: 
<if ($mybb->input['filtertf_fcat3']==Plugin) then><span class="tea"> Plugin</span>  [<a href="forumdisplay.php?fid={$fid}">Clear filter</a>]
<elseif 
($mybb->input['filtertf_fcat3']==ProPortalBlock) then><span class="tea">ProPortal Block </span> [<a href="forumdisplay.php?fid={$fid}">Clear filter</a>]
<elseif 
($mybb->input['filtertf_fcat3']==Modification) then><span class="tea">Modification</span> [<a href="forumdisplay.php?fid={$fid}">Clear filter</a>]
<else>
All 
</if>
</td>
</tr>
</table>


As I said, it does work, but that is a lot of ifs. I am also unsure how secure that filter is. Advice and suggestions to improve appreciated. In case it is not clear what I mean, here is a link to the forum I am testing this display on:   http://www.leefish.nl/mybb/forum-51.html



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 03-30-2012 09:24 AM by leefish.)
03-30-2012 09:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Showing a selected value

HTML Code
1
2
3
4
5
6
7
8
9
<td class="trow1" align="center"> Your Current Filters: 
<if $filters_set['fcat3']['value'] then>
<span class="tea">{$filters_set['fcat3']['value']}</span>  [<a href="forumdisplay.php?fid={$fid}">Clear filter</a>]
<else>
All
</if>
</td>
</tr>
</table>


For reference purposes, can be done without a conditional too

HTML Code
1
2
3
4
5
6
7
8
9
<td class="trow1" align="center"> Your Current Filters: 
<span style="{$filters_set['fcat3']['visiblecss']}">
<span class="tea">{$filters_set['fcat3']['value']}</span>  [<a href="forumdisplay.php?fid={$fid}">Clear filter</a>]
</span><span style="{$filters_set['fcat3']['hiddencss']}">
All
</span>
</td>
</tr>
</table>


See Documentation/undoc.html for information on the $filters_set array.


My Blog
(This post was last modified: 03-30-2012 12:16 PM by ZiNgA BuRgA.)
03-30-2012 12:13 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: Showing a selected value
Hmm, that is very similar to the first approach I tried, but the value is not showing in the display box now.

The filters work fine, but the displays are not showing - the display is at all.

The custom field is a textbox, it is set to everyone required. I have the default replacement value in as {value} and I also have a formatting map list:

Code:
Plugin{|}<a href="{$forumurl?}filtertf_fcat3=Plugin"><span style="color: green;"><strong>Plugin</strong></span></a>
Modification{|}<a href="{$forumurl?}filtertf_fcat3=Modification"><span style="color: green;"><strong>Modification</strong></span></a>
Theme{|}<a href="{$forumurl?}filtertf_fcat3=Theme"><span style="color: green;"><strong>Theme</strong></span></a>
Core File Edit{|}<a href="{$forumurl?}filtertf_fcat3=Core File Edit"><span style="color: green;"><strong>Core File Edit</strong></span></a>
ProPortalBlock{|}<a href="{$forumurl?}filtertf_fcat3=ProPortalBlock"><span style="color: green;"><strong>ProPortal Block</strong></span></a>



[Image: leelink.gif]
MYBB1.6 & XThreads
03-30-2012 12:27 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Showing a selected value
Oh, you've got it in the forumdisplay_searchforum_inline template.
In which case, you need to replace all instances of $filters_set with $GLOBALS['filters_set']

My Blog
03-30-2012 12:38 PM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Showing a selected value
Oh DUH at me. I am sorry - I should have said it was in a different template, sorry about that. Yes, it is now working perfectly and in the way I expected.

Thank you.

Just edit to add: I went with the version from ZingaBurga with the if conditional as that way the clear filters option only showed if there was a filter in use.


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 03-31-2012 01:20 AM by leefish.)
03-30-2012 12:48 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: