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.


configurable PT button in user block by each post...

Login / Search

 [ Join | More ]
 Add topic 
Posted
Item has a rating of 5 (Liked by GuestLiked by JeanLiked by Tisnart)  
Rating:
#90607 (In Topic #18305)
Avatar

Community saint

Ok, guess I'll move onto the next one, which is a little PT button.   Sort of like my on/offline modification.

The bulk of it will be pretty basic, and similar to the other modification.    Just need to look up how to make a url to creating a new PT with the member who's post you click into.   

Will be back with code as I have time and work my way through it.

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

Community saint

I guess first is to make the config option in the ocp_config table, I used the following sql:

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_pt_button', 'IS_ON_PT_BUTTON', 1, '1', 'tick', 'return ''1'';', 'SECTION_FORUMS', 'GENERAL', 'CONFIG_OPTION_is_on_pt_button', 0, '');

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

Community saint

Next is lang/EN/ocf_config.ini, where I added the text for the config screen:

Code

IS_ON_PT_BUTTON=Show PT button
CONFIG_OPTION_is_on_pt_button=Turn on/off an icon on the left of each post that allows users to start a PT with the member that made that post.

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

Community saint

Now if you go to adminzone->setup->config->member and forum options->general you get the option as seen in this graphic.  It lets you change and save it.

Of note to others, this is a real easy way to add configuration options you might want.  ;)


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

Community saint

in OCF_TOPIC_POST.tpl, added the code you can see here:

Code (php)


<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}
              <!-- PT button -->
              {+START,IF,{DO_PTBUTTON}}
                <a href='{PTBUTTONLINK}'><img  title="Start Personal Topic" alt="Start Personal Topic" src="{PTBUTTON*}" /></a>
              {+END}
                          <a href="#"><img title="{!BACK_TO_TOP}" alt="{!BACK_TO_TOP}" src="{$IMG*,top}" /></a>
                        </div>
                {+END}{+END}
             
    </td>
        </div>
 

Chris (or any other OCP people), how/where do I do text lie the 'start personal topic' above, so it is in a lang file instead of hardcoded?

edit:  changed the file above, will have code in viewtopic.php check the config variable, because in there I also need to check to see if the member that posted is = current member online, so it does not put a PT button for them, hence I will send the variable DO_PTBUTTON that will be send depending on those items.


Last edit: by Arbo

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

Community saint

Ok, I went to the users profile page to see what it uses for url to create a new PT with a user.. on my system it is forum/pg/topics/new_pt/## where ## is member number.

Seems clear, but I know I have the option for 'better' urls, and not all use that, so I need to find the code to generate the url depending on what the site uses.

So i found that link on the profile page and traced it back to ACTIONS_contact and sources/hooks/systems/profile_tabs/about.php ..

And that just added to the confusion.

So now I will let the aneurism clot for a while and will try again later.   

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

Chris (or any other OCP people), how/where do I do text lie the 'start personal topic' above, so it is in a lang file instead of hardcoded?

In the code you pasted above you can see how a language string is referenced via {!BACK_TO_TOP} – just do more of the same :).

Seems clear, but I know I have the option for 'better' urls, and not all use that, so I need to find the code to generate the url depending on what the site uses.

{$PAGE_LINK,forum:topics:new_pt:{POSTER_ID}} for the OCF_TOPIC_POST template (as {POSTER_ID} contains member ID)


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:
#90637
Avatar

Community saint

Ok, I'll have to figure out what language file such things are kept in.. but for now, skipping that and moving on.   

Ah, we can build links in temp code.. nice.  Thanks.

That changes my OCF_TOPIC_POST.tpl to this:
(for the needed section)

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}
              <!-- PT button -->
              {+START,IF_NON_EMPTY,{DO_PTBUTTON}}
                <a href='{$PAGE_LINK,forum:topics:new_pt:{POSTER_ID}}'><img  title="Start Personal Topic" alt="Start Personal Topic" src="{PTBUTTON*}" /></a>
              {+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>

Now working on the logic in the php file to check to make sure it's not a guest, and the user viewing isn't the user that posted.

Let me tell you the difference between IF_NOT_EMPTY and IF_NON_EMPTY …   One works, one causes 40 minutes of headaches figuring out what is wrong.  ;)

Paul
Back to the top
 
Posted
Item has a rating of 5 (Liked by GuestLiked by TisnartLiked by Duck)  
Rating:
#90638
Avatar

Community saint

Ok, after loosing a bit of my mind figuring out what would give me the currently online users id (get_member()) …  I have it working…   

In topicview.php, I added the following code above // Avatar

Code (php)

               // PT Button:  Show for each user that is not the one viewing post, but not if guest
             
               if ( (get_option('is_on_pt_button')) && (!(is_guest())) && ($_postdetails['poster'] != strval(get_member())) ){
                 $do_pt_button = '1';
               } else {
                 $do_pt_button = '';
               }

                                // Avatar
 

Then further down at the end of the rendered_post=do_template … added the following two…

Code (php)

'DO_PTBUTTON'=>$do_pt_button,
                                                        'PTBUTTON'=>find_theme_image('personaltopic'),

Now, guests will not see the button (as they shouldn't be able to start a PT with anyone anyway), if it is your own post you are viewing the button does not show either.

Yeehaa!   Another one down.    Anyone else actually interested in this stuff?


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

Community saint

Here's a screen capture showing those blocks where it shows for a different users post, but not mine, as it should do.

Also attached the personaltopic image I use with this modification.

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

Community saint

Added this into tracker as a suggestion to be included in future versions:

0000814: PT Button in posters info next to each post. - ocPortal feature tracker

Paul
Back to the top
 
Posted
Rating:
#90645
Avatar

Community saint

Arbo said

Yeehaa!   Another one down.    Anyone else actually interested in this stuff?

Yep! :thumbs:

Steve
Back to the top
 
Posted
Rating:
#90676
Avatar

Community saint

sholzy said

Arbo said

Yeehaa!   Another one down.    Anyone else actually interested in this stuff?
Yep!


Wonderful!
Thanks for sharing!
:thumbs:
Back to the top
 
Posted
Item has a rating of 5 (Liked by JeanLiked by BobS)  
Rating:
#90679
Avatar

Community saint

I gave it a 'Like' Arbo, but you deserve to be encouraged more than that!

I've bookmarked the stuff you've so magnanimously made available to the community, and I am SURE that I shall be adding one or all of the features in future site builds.

For the moment I am just struggling to get my head around the MAJOR changes to CSS and TEMPLATING between 9.x.x and earlier versions. But I suspect that 'familiarity' with the new or changed stuff in 9 will soon have me moving onward and forward in a pretty short time.

Thanks, again!

 :thumbs:

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Item has a rating of 5 (Liked by BobS)  
Rating:
#90721
Avatar

Community saint

Thanks.

Now I'm trying to figure out which thing to work on/do next…


Paul
Back to the top
 
Posted
Rating:
#90835
Avatar

Community saint

Nice work. I like and will likely use. You should commit to github
Back to the top
 
Posted
Rating:
#90855
Avatar

Community saint

Thanks, I'm not even sure I want to figure out what github is and how it works, even if Chris allowed it.    Thus I just put it in as a ticket requesting it just be included in the future.

Paul
Back to the top
 
Posted
Rating:
#90920
Avatar

Community saint

Chris (or anyone else that might have some idea):

I noticed a 'bug' with this code, the PT button and the user online icon mod.    

When you hit the reply button, you get the screen to enter your reply, below it shows the previous messages in the thread, and I get warnings about variables used in OCF_TOPIC_POST not being available.    In topicview.php I pass them, and it seems topics.php does the 'reply' option, but doesn't call the OCF_TOPIC_POST …  so how/where is it being called to I can fix this?   Having a tough time following the 'flow'..

Thanks.

Paul
Back to the top
 
Posted
Rating:
#90921
Avatar

In sources/ocf_posts2.php ?


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
Rating:
#90922
Avatar

Community saint

Ah, thanks.    Ok, so for this mod and the useronline mod, you also need the little bit of code at the bottom of sources/ocf_posts2.php …

I just send blank stuff so nothing shows, since during typing a reply none of these icons really matters.  You need to add USER_ONLINE, DO_PTBUTTON and PTBUTTON as below at the end of the file.

Will post this on the other mod thread too.

Code (php)

                                        'DESCRIPTION'=>'',
                                        'PREVIEWING'=>true,
                                        'RATING'=>$rating,
                                        'USER_ONLINE'=>'',
                                        'DO_PTBUTTON'=>'',
                                        'PTBUTTON'=>'',
                        ))
        ));
}

Paul
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: