[2.1] $pf['input']['after'] & Likes

Started by Antes, March 04, 2019, 06:18:22 AM

Previous topic - Next topic

Antes

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.

Suki

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.

Antes

In display.template, I integrated likes button into my own list-collection (qbuttons)

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
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.

Sesquipedalian

#3
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.


$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.
I promise you nothing.

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

Advertisement: