phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Viewforum.php (topics or posts) column only appeared for....


 
Search this topic... | Search phpBB2 Discussion... | Search Box
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Author Message
JLA
Board Member



Joined: 30 Apr 2009

Posts: 298
Location: U.S.A


flag
PostPosted: Mon Sep 12, 2011 7:31 pm 
Post subject: Viewforum.php (topics or posts) column only appeared for....

We were trying to layout tests and for some reason cannot figure out the typical way to have the topic or posts column (numbers) only appear for say the admin or logged in user, etc as an example

Tried the typical if ($userdata['user_level'] == ADMIN) {

}

in the template (using <?PHP ?>) but it is not picking that up. Is $userdata not passed to the viewforum.php template similar to the way $postrow[$i] is in the viewtopic.php template?

_________________
http://www.jlaforums.com
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Mon Sep 12, 2011 8:13 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

In the template? .tpl files can't take php, you'll need to do it on the program side in viewforum.php. Unless there's a specific script to check user level in .tpl files, but I haven't heard about it.
Back to top
JLA
Board Member



Joined: 30 Apr 2009

Posts: 298
Location: U.S.A


flag
PostPosted: Mon Sep 12, 2011 9:12 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Salvatos wrote:
In the template? .tpl files can't take php, you'll need to do it on the program side in viewforum.php. Unless there's a specific script to check user level in .tpl files, but I haven't heard about it.


Yes you can. Use <?php WHATEVER ?> Example, we use this for placing certain content into certain posts in a thread or displaying certain things on a page/specific place on a page in one scenario but not another.

http://www.phpbbstyles.com/viewtopic.php?t=80

_________________
http://www.jlaforums.com
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Mon Sep 12, 2011 9:24 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Ah, I didn't know XS allowed that. Judging from the topic you linked, $userdata is probably a global, so make sure you declare it as such. (I don't know much about globals, so I may be wrong again.)
Back to top
JLA
Board Member



Joined: 30 Apr 2009

Posts: 298
Location: U.S.A


flag
PostPosted: Fri Sep 16, 2011 8:39 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Salvatos wrote:
Ah, I didn't know XS allowed that. Judging from the topic you linked, $userdata is probably a global, so make sure you declare it as such. (I don't know much about globals, so I may be wrong again.)


Ill check that and see if it works.

Thanks

_________________
http://www.jlaforums.com
Back to top
lumpy burgertushie
Board Member



Joined: 19 Nov 2008

Posts: 214


flag
PostPosted: Thu Sep 29, 2011 4:49 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Code:
#-----[ OPEN ]------------------------------------------
#

includes/page_header.php

#
#-----[ FIND ]------------------------------------------
#

if ( !empty($userdata['user_popup_pm']) )
   {
      $template->assign_block_vars('switch_enable_pm_popup', array());
   }
#
#-----[ AFTER, ADD ]------------------------------------------
#

// Admin Only View Mod   
   if ( $userdata['user_level'] == ADMIN )
   {
      $template->assign_block_vars('switch_admin_view_only', array());
   }
// Admin Only View Mod

then use the switch to surround whatever you want only admins to see:

<!-- BEGIN switch_admin_view_only -->
<!-- END switch_admin_view_only -->
Back to top
JLA
Board Member



Joined: 30 Apr 2009

Posts: 298
Location: U.S.A


flag
PostPosted: Fri Sep 30, 2011 2:32 am 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

lumpy burgertushie wrote:
Code:
#-----[ OPEN ]------------------------------------------
#

includes/page_header.php

#
#-----[ FIND ]------------------------------------------
#

if ( !empty($userdata['user_popup_pm']) )
   {
      $template->assign_block_vars('switch_enable_pm_popup', array());
   }
#
#-----[ AFTER, ADD ]------------------------------------------
#

// Admin Only View Mod   
   if ( $userdata['user_level'] == ADMIN )
   {
      $template->assign_block_vars('switch_admin_view_only', array());
   }
// Admin Only View Mod

then use the switch to surround whatever you want only admins to see:

<!-- BEGIN switch_admin_view_only -->

<!-- END switch_admin_view_only -->



This is very odd - but for some reason - this is not working (and it should be)

_________________
http://www.jlaforums.com
Back to top
JLA
Board Member



Joined: 30 Apr 2009

Posts: 298
Location: U.S.A


flag
PostPosted: Fri Sep 30, 2011 2:54 am 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Possible not working because it is a nested block var?

Using inside topicrows

_________________
http://www.jlaforums.com
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Fri Sep 30, 2011 5:30 am 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Wouldn't it be better to use an IF clause? I don't know how those are created in the templates and don't have time to look, but it seems to me that it would be more appropriate for what you are trying to do. Basically you keep the postrow loop going normally, but you ony let it display results if the IF gets verified, otherwise it skips to the next.
Back to top
JLA
Board Member



Joined: 30 Apr 2009

Posts: 298
Location: U.S.A


flag
PostPosted: Fri Sep 30, 2011 2:27 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Salvatos wrote:
Wouldn't it be better to use an IF clause? I don't know how those are created in the templates and don't have time to look, but it seems to me that it would be more appropriate for what you are trying to do. Basically you keep the postrow loop going normally, but you ony let it display results if the IF gets verified, otherwise it skips to the next.


As I mentioned in the initial post

Quote:
if ($userdata['user_level'] == ADMIN) {

}


That wasn't working either. Kinda of scratching my head on this one....

_________________
http://www.jlaforums.com
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Fri Sep 30, 2011 5:20 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

I mean as an in-template condition. For example Simple Subforums has this:
Code:
<!-- IF PARENT_FORUM --> -> <a class="nav" href="{U_VIEW_PARENT_FORUM}">{PARENT_FORUM_NAME}</a> <!-- ENDIF -->


Built from:
Code:
         $template->assign_vars(array(

            'PARENT_FORUM'         => 1,

            'U_VIEW_PARENT_FORUM'   => append_sid("viewforum.$phpEx?" . POST_FORUM_URL .'=' . $all_forums[$i]['forum_id']),

            'PARENT_FORUM_NAME'      => $all_forums[$i]['forum_name'],

            ));
Back to top
JLA
Board Member



Joined: 30 Apr 2009

Posts: 298
Location: U.S.A


flag
PostPosted: Fri Sep 30, 2011 6:23 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

We were trying to do something like this in say the viewforum template

<?php
if ($userdata['user_level'] == ADMIN) { ?>
<tr>
<td>
Admin row contents</td>
</tr>
<?php
} else { ?>
<tr>
<td>
Normal user row contents</td>
</tr>
<?php } ?>

_________________
http://www.jlaforums.com
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Fri Sep 30, 2011 8:06 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Oh, if it's just that you don't even need to edit the template file. You could just get your content variable in viewforum.php and put your condition there with the alternate value.

e.g. (using a template assign at random here)
Code:
      if ($userdata['user_level'] == ADMIN) {
         $template->assign_vars(array(
         'META' => 'something')
         );
      }
      else {
         $template->assign_vars(array(
         'META' => 'something else')
         );
      }
Back to top
JLA
Board Member



Joined: 30 Apr 2009

Posts: 298
Location: U.S.A


flag
PostPosted: Sat Oct 01, 2011 8:34 pm 
Post subject: Re: Viewforum.php (topics or posts) column only appeared for

Ok, I figured this out for the various sections.

In Lumpy's solution, you have to add before
$template->assign_block_vars('info_switch', array());

and you do not have to put in the page header, but only on the page you want to work with (we have multiple page headers so it is easier to just put on the page we are using it)

For items that use rows like topicrow, etc - a different solution

You find the item you want in the template assign

Example
'L_REPLIES' => $lang['Replies'],

would change to

'L_REPLIES' => ($userdata['user_level'] == ADMIN) ? $lang['Replies']: '',

Thanks for everyone's input on this.

_________________
http://www.jlaforums.com
Back to top
Display posts from previous:   
Register or Login to Post    Index » phpBB2 Discussion  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0214 seconds using 15 queries. (SQL 0.0025 Parse 0.0006 Other 0.0183)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo