Help - Search - Members - Calendar
Full Version: Modification Question: Topic View
Invision Power Services > Community Forums > Community General Chat
VortMax
Hello, my modification I wrote displays data underneath the Member # in the topic view. I let each user determine what kind of data is displayed to the rest of the board via logic in RenderRow. But what I want to also be able to do is have the user be able to Display or not display this data. When I use the logic in RenderRow to remove it, it only removes that particular persons data and not the other members. Anyone have any pointers?

Thanks
neocodex
create some rows in member_extra and make the option in forms in my controls or something to let them set it.

then add something like
CODE
$author['my_data']
in the RenderRow template bit.

in sources/lib/topic_linear.php you can make all your logic (towards the bottom) and you dont need any sort of html logic. You can have as many nested if statements as you want.

I particularly dont like html logic and prefer to stay away from it.
VortMax
This is in IPB 2.1 BTW.

I am using the HTML logic in the RenderRow right now and that works fine for displaying what the user wants other people to see. What I need to do is to turn off this data if the member does not want to see it. For example. Members 1 through 500 are displaying data in each topic under their member number (got all of this working fine)

Member's 1 through 500 are content with viewing the others people data. But member 501 does not want to see the data that the other users are displaying. <---This is the trouble I am having.
VortMax
I think I might have figured it out with your help.

in linear_topic I will create an if then for the control panel switch and then just have two "RenderRow" outputs. One with weather and one without. That should do it right?

Edit: Maybe not, that might still just turn off the one particular persons data and not everyones?
bfarber
Your better bet is to use the HTML Logic to determine if you WANT to display the data at all, and then determine WHAT data to display in the source file. wink.gif Similar concept, but you'd have to rework it slightly based on how you are doing it now.
neocodex
QUOTE(bfarber @ Sep 16 2005, 09:54 AM) *
Your better bet is to use the HTML Logic to determine if you WANT to display the data at all, and then determine WHAT data to display in the source file. wink.gif Similar concept, but you'd have to rework it slightly based on how you are doing it now.
An expert has spoken tongue.gif

I just dont have HTML logic experience and i tend to shy away from it tongue.gif
VortMax
That's what I did.

Another problem has occured. I am saving a variable via the members control panel either = -1 (no) 0 (yes).

This variable is stored in $member(view_wd)

Problem is it displays each members variable and not the person who is viewing the page. So if three posts by three different members is viewed that variable shifts from 0 to -1 to 0 etc.

Acutally, I used HTML logic to display what data is displayed and then was using the source to determin whether or not the data is displayed at all.
neocodex
it sounds like you are using the ipb caching system to pull the variable rather than pulling it from the db for the poster. look around in the topic_linear.php code and you will find a variable that is the posters ID. Then you can construct a sql query to pull that variable from the member_extra table or wherever you stored it.

This isnt an issue, but as general programming etiquete you should have 0 being no and 1 being yes. This is a reference to binary as 1 is on and 0 is off. Its just how its always done, but dont change it if you are used to -1 as off and 0 as on. It just struck me as a bit odd. But programming is more about you understanding the concepts so if you like it that way, then leave it original.gif. having it with 0 as off and 1 as on will enable you to do something like this:
CODE
$x = 0;
if($x)
{
//this code wont be executed because $x is 0 :D
}
but then you could just as easily do something like this:
CODE
$x = -1;
if($x == 0)
{
//this code wont be executed because $x is not equal to 0 :D
}
VortMax
CODE

             if ($member['view_wd'] == -1)
             {
                   $this->output .= $this->ipsclass->compiled_templates['skin_topic']->render_data_row( $row, $poster );
             }

             if ($member['view_wd'] == 0)
             {
                   $this->output .= $this->ipsclass->compiled_templates['skin_topic']->RenderRow( $row, $poster );
             }


The other problem with above is member[view_wd] is showing a null value in linear_topic.php but it topics.php it contains a value.


Yeah,
been using the caching system to get all my varibles. I am not real good with mysql. Wouldn't really know where to start.

Yeah I understand the code. I have been programing for many years. It's like that because it appears like usercp.php like that and I copied the code from there. biggrin.gif
neocodex
I dont have access to the actual scripts right now, but i believe there is a array element of like $poster['id'] in that array. What you can do is:
CODE
$results = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'view_wd', 'from' => 'member_extra', 'where' => 'id='.$poster['id'] ) );
Then you can access the view_wd variable like this:
CODE
$results['view_wd']
and maybe give it a key in the $poster array like:
CODE
$poster['view_wd'] = $results['view_wd']
which will then enable you to put something like
CODE
$author['view_wd']
in the RenderRow original.gif
VortMax
let me give that a shot real fast. I store that variable in another table though so I will have to change it.
neocodex
QUOTE(VortMax @ Sep 16 2005, 10:55 AM) *
Yeah I understand the code. I have been programing for many years. It's like that because it appears like usercp.php like that and I copied the code from there. biggrin.gif
Oh. Naughty Matt shifty.gif


QUOTE(VortMax @ Sep 16 2005, 10:58 AM) *
let me give that a shot real fast. I store that variable in another table though so I will have to change it.
Shouldnt be a problem original.gif
VortMax
Hmm tried the above code.

When I try to echo $results it gives me "Array" as the result.

OK
When I tried to echo $results['view_wd] it is still retunring the the result for each post in the thread instead of the value for the person viewing the thread (me) any ideas?

CODE
         while ( $row = $this->ipsclass->DB->fetch_row( $oq ) )
         {

             $return = $this->lib->parse_row( $row );
            
             $poster = $return['poster'];

             $row    = $return['row'];


The above is what is the problem. each topic line that is written is advancing the poster[id]

I need to fetch that variable for the user that is presently viewing the thread. how might I do that?
VortMax
Got it working!

Changed the .poster[id] to .member[if]

$results = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'view_wd', 'from' => 'members', 'where' => 'id='.$this->ipsclass->member['id'] ) );


Perfect!
neocodex
hmm...thats a bit weird that you are using $this->ipsclass->member['id'] as thats the ID of the person who is viewing the thread and not the ID of the poster of that post. But i suppose if everything is working then cool original.gif.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.