HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Adding a 'user online' icon that is configurable...

Login / Search

 [ Join | More ]
 Add topic 
Posted
Item has a rating of 5 (Liked by JeanLiked by Chris GrahamLiked by Guest)  
Rating:
#90569 (In Topic #18302)
Avatar

Community saint

Ok, I guess I will just get started and get to digging into the code.

I want, on each message, where it shows the posts user information, to have a few things, the first is a user is online/offline little icon.  I did this back in v7, of course it's gone once I upgraded to v9.   But now I want to put it in as a configuration item where it can be turned on/off as I think this would be one of many small things that can be added to OCP in the future.

I know the setup->configuration uses a database to store the configuration.   But at first look, admin_config.php looked a little confusing.   So I backtracked a bit further, and decided to start by puttting the config option into the database.

So in ocp_config (table), I added the following record, based on looking at what other on/off options related to the forum were:

Code


INSERT INTO `ocp_config` (`the_name`, `human_name`, `c_set`, `config_value`, `the_type`, `eval`, `the_page`, `section`, `explanation`, `shared_hosting_restricted`, `c_data`) VALUES
('is_on_show_online', 'IS_ON_SHOW_ONLINE', 1, '0', 'tick', 'return is_null($old-get_value(''no_show_online''))?''1'':invert_value($old);', 'SECTION_FORUMS', 'GENERAL', 'CONFIG_OPTION_is_on_show_online', 0, '');


Next I will have to go back into admin_config.php and figure out where/what I need to do to add this into the actual screen and for processing, if there is anything at all, it may automatically be handled, and just need a language file entry.    That's the next step.  Will return once I dig into that part. 

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90571
Avatar

Community saint

Ok, admin_config.php handles the new config option automatically.  It was just a matter of looking in the database to see what other on/off items used as a return.  So I got that right.

Now, in lang/EN/ocf_config.ini  I had to add:

Code

IS_ON_SHOW_ONLINE=Enable on/Offline image
CONFIG_OPTION_is_on_show_online=Show user online/Offline Icon on the left of each post for user that posted the message.


As the title used as 'explanation' in the db is used as the description on the config page, then I figured out you take off the CONFIG_OPTION_ and that is used as the label in the left column.   

Example image attached of outcome.

Next is learning how to read that config value in the code, add code that passes it to the proper template, and modifying the template to show the proper graphic.  ;)


Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90573
Avatar

Community saint

I have been reading the tempcode 'guide', and am unsure, is there a method in tempcode to check the status of a configuration variable?

Paul
Back to the top
 
Posted
Rating:
#90580
Avatar

Community saint

Arbo said

I have been reading the tempcode 'guide', and am unsure, is there a method in tempcode to check the status of a configuration variable?
I can't see any obvious generic way of reading it in the template without it being passed as a parameter to the template.

To add it as a named parameter to a specific template you would add your named parameter to the do_template() line. i.e. add something like:

Code

,'IS_ON_SHOW_ONLINE'=>get_option('is_on_show_online'))

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90581
Avatar

Community saint

Yeah, I think that's how I did it in the past.   So I'll have to add that and a check to see if the user is online and pass that as well.

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90583
Avatar

Community saint

Ok, the basics are done after looking back at my v7 mod... 

In forum/pages/modules/topicview.php,  look for //Avatar and before that added:

Code


// user online/offline
if (member_is_online($_postdetails['poster'])) {
$poster_online=do_template('OCF_TOPIC_POST_ONLINE',array('_GUID'=>'d647ada9c11d56eedc0ff7894d33e83c','OSTATUS'=>find_theme_image('ison')));
} else {
$poster_online=do_template('OCF_TOPIC_POST_ONLINE',array('_GUID'=>'d647ada9c11d56eedc0ff7894d33e83c','OSTATUS'=>find_theme_image('isoff')));
}


Then search down for: 

Code


$rendered_post=do_template('OCF_TOPIC_POST';,array(


At the bottom of that list, add USER_ONLINE and IS_ON_SHOW_ONLINE lines:

Code


'USER_ONLINE'=>$poster_online,
'IS_ON_SHOW_ONLINE'=>get_option('is_on_show_online'),


.


Last edit: by Arbo

Paul
Back to the top
 
Posted
Rating:
#90584
Avatar

Community saint

I am NO fan of this cut and paste stuff in v9, something is different, it doesn't let you post clean code any more.

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90585
Avatar

Community saint

OCF_TOPIC_POST.tpl

This one needs adjusting, as the alignment is off, not sure how this div thing works with css… i always still used tables.

Code

<div>
   <div class="ocf_left_post_buttons {CLASS*}">
      {EMPHASIS*}
      
      {+START,IF,{IS_ON_SHOW_ONLINE}}
          &nbsp;{USER_ONLINE}
        {+END}

      {+START,IF_EMPTY,{EMPHASIS}}{+START,IF_NON_EMPTY,{ID}}
         <div class="ocf_post_back_to_top">
            <a href="#"><img title="{!BACK_TO_TOP}" alt="{!BACK_TO_TOP}" src="{$IMG*,top}" /></a>
         </div>
      {+END}{+END}
             
    </td>
   </div>

   <div class="buttons_group post_buttons ocf_post_main_column">
      {BUTTONS}
   </div>
</div>


and a new tpl file.   OCF_TOPIC_POST_ONLINE.tpl :

Code

<img  title="" alt="Online Status" src="{OSTATUS*}" />

Now when I go to config and turn the option on and off, it does turn that little online icon on and off.    Oh, you need an ison.png and an isoff.png as well, as that's what it uses.

Will fiddle with alignment tomorrow I guess.

Paul
Back to the top
 
Posted
Rating:
#90592
Avatar

This bit:

Code

return is_null($old-get_value(''no_show_online''))?''1'':invert_value($old);
is more complex than it needs. Simply:

Code

return \'1\';
:)

(The more complex code we had there will have been creating a new option while making its default value the same as an old hidden option - you don't have that requirement)

The add_config_option function does this query. So the correct (and shorter ;)) way is as follows:

Code

add_config_option('IS_ON_SHOW_ONLINE','is_on_show_online','tick','return \'1\';','SECTION_FORUMS','GENERAL');

If you're not running this from an install() function then you'll need to load up the file that has the function:

Code

require_code('database_action');
add_config_option('IS_ON_SHOW_ONLINE','is_on_show_online','tick','return \'1\';','SECTION_FORUMS','GENERAL');

is there a method in tempcode to check the status of a configuration variable?

In PHP, it's get_option('is_on_show_online') and in Tempcode it's {$CONFIG_OPTION,is_on_show_online}.

I am NO fan of this cut and paste stuff in v9, something is different, it doesn't let you post clean code any more.

I don't follow. Is this relating to pasting here? We're actually running a bastardised v8 on here ;).
I tend to keep the WYSIWYG off, it's not great for code posting.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 5 (Liked by Chris Graham)  
Rating:
#90593
Avatar

Community saint

Chris Graham said

in Tempcode it's {$CONFIG_OPTION,is_on_show_online}.
Good to know.

F.Y.I. {$CONFIG_OPTION,...} is not in the Tempcode tutorial.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90594
Avatar

Community saint

Ok, so OCF_TOPIC_POST.tpl should be modified as  this:

Code

<div>
   <div class="ocf_left_post_buttons {CLASS*}">
      {EMPHASIS*}
      
      {+START,IF_EMPTY,{EMPHASIS}}{+START,IF_NON_EMPTY,{ID}}
         <div class="ocf_post_back_to_top">
           <!-- is on/offline -->
           {+START,IF,{$CONFIG_OPTION,is_on_show_online}}
                {USER_ONLINE}
              {+END}

           <a href="#"><img title="{!BACK_TO_TOP}" alt="{!BACK_TO_TOP}" src="{$IMG*,top}" /></a>
         </div>
      {+END}{+END}
             
    </td>
   </div>

   <div class="buttons_group post_buttons ocf_post_main_column">
      {BUTTONS}
   </div>
</div>

forum/pages/modules/topicview.php should add the following before // Avatar:

Code (php)

               if (member_is_online($_postdetails['poster'])) {
                 $poster_online=do_template('OCF_TOPIC_POST_ONLINE',array('_GUID'=>'d647ada9c11d56eedc0ff7894d33e83c','OSTATUS'=>find_theme_image('ison')));
               } else {
                 $poster_online=do_template('OCF_TOPIC_POST_ONLINE',array('_GUID'=>'d647ada9c11d56eedc0ff7894d33e83c','OSTATUS'=>find_theme_image('isoff')));
               }
 

And below that at the end of the $rendered_post= add just:

Code

'USER_ONLINE&'=>$poster_online,

You need the new OCF_TOPIC_POST_ONLINE.tpl as well:

Code

<img  title="" alt="Online Status" src="{OSTATUS*}" />

In the database table ocp_config, add the following record:

Code

INSERT INTO `ocp_config` (`the_name`, `human_name`, `c_set`, `config_value`, `the_type`, `eval`, `the_page`, `section`, `explanation`, `shared_hosting_restricted`, `c_data`) VALUES
('is_on_show_online', 'IS_ON_SHOW_ONLINE', 1, '0', 'tick', 'return ''1'';', 'SECTION_FORUMS', 'GENERAL', 'CONFIG_OPTION_is_on_show_online', 0, '');

(Chris, is 'eval' just it's intital value or something?  Either way, you are right, it still toggles properly in the config screen with it set as you say)

You also need the following in lang/EN/ocf_config.ini   (for it seems even using add_config_option doesn't add these, as you don't pass it the data for what to say)

Code

IS_ON_SHOW_ONLINE=Enable On/Offline image<br />
CONFIG_OPTION_is_on_show_online=Show user Online/Offline Icon on the left of each post for user that posted the message.<br />

Next post I'll attached the ison and isoff images I use since they fit the size of the up arrow graphic that is already there. As well as a screen shot of what it looks like.


Last edit: by Arbo

Paul
Back to the top
 
Posted
Rating:
#90595
Avatar

(Christ, is 'eval' just it's intital value or something?  Either way, you are right, it still toggles properly in the config screen with it set as you say)

Yes, it is PHP code that runs to find its default value.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90596
Avatar

Community saint

In the above OCF_TOPIC_POST.tpl I moved the code inside the same div as the up arrow, so things are alined properly.

Chris, it must be a WYSIWYG editor for code posting as the above I did in the quick reply and they work fine.

Attached are my ison.png and isoff.png files, and screen shots showing how it looks when this is installed and turned on, both for user online and user offline.

I guess this concludes this 'mod'.   I'd like to see this built into v10.  ;)

Thanks for your time, this went a lot quicker than I thought it would. 



Paul
Back to the top
 
Posted
Rating:
#90597
Avatar

Community saint

damnit, I edited the message with the code, didn't edit the code blocks, and when saved it added a lot of nbsp's in there.    What a pain the wysiwyg editor is, now let me find my options try to turn it off and fix that crap so it's readable.

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by FletchLiked by JeanLiked by Robbie GoacherLiked by sholzyLiked by GuestLiked by kenno)  
Rating:
#90598
Avatar

I'd suggest adding a tracker issue for this and linking to here. I'd certainly consider merging this at some point.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 5 (Liked by FletchLiked by TisnartLiked by sholzyLiked by Guest)  
Rating:
#90600
Avatar

Community saint

Ok, found the tracker stuff and filled it out as best I could figure out.  It is here:

0000810: Show user on/offline on forum - ocPortal feature tracker

Now, to determine what to work on next. ;)

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90602
Avatar

Arbo said

Ok, found the tracker stuff and filled it out as best I could figure out.  It is here:

0000810: Show user on/offline on forum - ocPortal feature tracker

Now, to determine what to work on next. ;)

Keep it up and I might have to hand out github commit access to you ;).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 5 (Liked by Robbie GoacherLiked by sholzyLiked by Guest)  
Rating:
#90604
Avatar

Community saint

That sounds like a lot of even more confusing stuff to figure out, whatever it is.

I think next will be some similar configurable icons that are for sending private topics, and such.  

I know you can hover over the users name and get a popup that shows the online status, but in a 'quick and easy' world we live in, seeing such a thing at a glance seems like what most users prefer.  Thus this modification.

The icon for PT is due to the same theory, you can click on the name go to their page and send a PT from there, but that is too many steps for the 'quick and easy' world.  ;)    I'd like to have a permanant 'location' field in the user record as well, so people can put in their location, be it real or fictional, and if it is entered, it is added below the name in that box.   I know this is a common feature in other forum software, and again, it goes to the quick and easy about seeing who the user is and info about them quickly.

I was thinking about the 'awards' system as well, many forums have awards, but they are done differently, some automatically, like when you hit 5k posts, you get a little icon in that box identifying you as someone that hit the 5K mark, or perhaps a little 'well liked user' icon that shows up once you hit so many likes on your posts by other users.    

All towards that quick and easy, as well as recognition, which drives people.

And of course, the drive to have them in the configuration is that not everyone that uses OCP might want such an option turned 'on'. ;)

Paul
Back to the top
 
Posted
Rating:
#90626
Avatar

PT- isn't this what the whisper button does?

Location field - Tempcode can do quite easily, {$CPF_VALUE,Location,{ID}} [assumes OCF_POSTER_MEMBER template, and CPF entitled Location]

"I was thinking about the 'awards' system as well" – an ocf_implicit_usergroups hook should work as a foundation. See the under18s non-bundled addon as an example (automatically puts everyone under 18 in a special usergroup, which you can then e.g. assign a rank image to).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#90627
Avatar

Community saint

I diable the wisper function, because to me it doesn't make sense.  Private conversations between two users inside of a thread?   Confusing.   I see if I hit the whisper button it goes to a page where you pick the in thread version or start a private topic, but again, that is an extra step.   And the fast and easy generation wants less steps.   But that's just my view, and how I see things trending.

But location isn't a standard field in each users record is it?   It never was before, and I remember having to figure out how to pull this info from an 'extra' field in v7.

I will look at the under18s package when I get a chance.   I don't want it to put people in a usergroup and use that rank image, but it may give me a good base to start looking at.  Thanks.

Paul
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Expand