Advertisement:

Author Topic: [2.1] $pf['input']['after'] & Likes  (Read 634 times)

Offline Antes

  • Evil Black Cat
  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,911
  • Gender: Male
  • Black cat rulz!
    • Antes on GitHub
    • merta on LinkedIn
    • @XinYenFon on Twitter
    • Patreon
[2.1] $pf['input']['after'] & Likes
« on: March 04, 2019, 06:18:22 AM »
I'm curious how I'm gonna manipulate those two areas.
I literally have no clue how "after" constructed or how a theme can manipulate its output so I'm waiting for dev input on this.
About likes, ??? The code & how its handled makes no sense, its just changing everything it contains and remove others...

Thanks.
You can support me directly via Patreon

In Catnip We Trust.
The solution is Catnip!
Vote for Catnip!

Current Project(s): [ WoWSnips ] # [ Lunarfall ] # [ RDD (HTML5) ] # [ ResponsiveCurve_Extras(SoonTM) ]
Past Project(s): [ ezPortal ]

Offline Suki

  • Kaizoku Jotei
  • On Hiatus
  • SMF Super Hero
  • *
  • Posts: 15,415
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: [2.1] $pf['input']['after'] & Likes
« Reply #1 on: March 04, 2019, 10:43:58 AM »
Which part?  theres multiple places where likes code is involved.

copy/pasting specific code parts will greatly help in trying to understand what you want to do.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Look at them. They're just asking for it. Maybe the human race deserves to be wiped out.

Offline Antes

  • Evil Black Cat
  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,911
  • Gender: Male
  • Black cat rulz!
    • Antes on GitHub
    • merta on LinkedIn
    • @XinYenFon on Twitter
    • Patreon
Re: [2.1] $pf['input']['after'] & Likes
« Reply #2 on: March 04, 2019, 01:09:35 PM »
In display.template, I integrated likes button into my own list-collection (qbuttons)

Code: [Select]
echo '
<ul class="qbuttons">';

// Likes
if (!empty($message['likes']['can_like']))
echo '
<li id="msg_', $message['id'], '_likes"', $ignoring ? ' style="display:none;"' : '', '><a href="', $scripturl, '?action=likes;ltype=msg;sa=like;like=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" class="msg_like" title="', $message['likes']['you'] ? $txt['unlike'] : $txt['like'], '"><i class="fa fa-thumbs-', $message['likes']['you'] ? 'down' : 'up', ' fa-lg"></i></a></li>';

And changed my template_like into
Code: [Select]
function template_like()
{
global $context, $scripturl, $txt;

if (!empty($context['data']['can_like']))
echo '
<li id="', $context['data']['type'], '_', $context['data']['id_content'], '_likes"', '>
<a href="', $scripturl, '?action=likes;ltype=', $context['data']['type'], ';sa=like;like=', $context['data']['id_content'], ';', $context['session_var'], '=', $context['session_id'], '" class="', $context['data']['type'], '_like"><i class="fa fa-thumbs', $message['likes']['you'] ? 'down' : 'up', '"></i> ', $context['data']['already_liked'] ? $txt['unlike'] : $txt['like'], '</a>
</li>';
}

Once someone likes a content, SMF changes whole qbuttons into this template, what I think it just needs to change the "like" part.
You can support me directly via Patreon

In Catnip We Trust.
The solution is Catnip!
Vote for Catnip!

Current Project(s): [ WoWSnips ] # [ Lunarfall ] # [ RDD (HTML5) ] # [ ResponsiveCurve_Extras(SoonTM) ]
Past Project(s): [ ezPortal ]

Offline Sesquipedalian

  • The Mad Doctor
  • Lead Developer
  • Sr. Member
  • *
  • Posts: 798
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: [2.1] $pf['input']['after'] & Likes
« Reply #3 on: March 25, 2019, 08:37:06 AM »
Regarding the posting field ($pf) values, $pf['label'] contains all the info to build the <dt> part of the template, and $pf['input'] contains all the info to build the <dd> part. Within each of those there are optional "before" and "after" components. When defined at all, these contain literal HTML strings that should be inserted before/after the rest of the content of the <dt> or <dd>.

For example, if you wanted your theme to include a giant picture of a hot dog after the input field for the subject, you could add the following just above this line.

Code: [Select]
$context['posting_fields']['subject']['input']['after'] = '<img src="https://chompies.com/wp-content/uploads/2017/03/HotDog.png">';

Connected with this, see https://github.com/SimpleMachines/SMF2.1/pull/5538, which adds a bunch of documentation and makes some minor tweaks to simplify the handling of the select and radio_select posting field types.
« Last Edit: March 25, 2019, 05:26:09 PM by Sesquipedalian »
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.