Advertisement:

Author Topic: loadPartialTemplate function Please?  (Read 29846 times)

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
loadPartialTemplate function Please?
« on: November 08, 2015, 05:21:30 AM »
Thing that has always bothered me in SMF, and is still bothering me in SMF 2.1.  You really need the ability to create partial templates, for functionality added to specific functions in SMF.  Integration Hooks can only do so much, and it's just not flexible enough.

The main problem is, SMF seems to control too much on this part.  The loadTemplate function is too damn strict and loads up entire HTML, than if you want to load a subtemplate, you are stuck with a function name inside of that template file.  This is the main problem here!

I want to add new functionality to SMF that will work in all Themes, but problem is, I have to code for entire theme files, for loadTemplate()

This should not be the case.  I should be able to integrate into a function called, loadPartialTemplate or something similiar, where it will grab only the file I specify to be loaded from the current theme, and into the part of the template automatically via Load.php (Source File).  However, in a source file, one can't simply do:

Code: [Select]
$context['my_partial_template'] = loadPartialTemplate('MyTemplate', 'MyFunction', $function_params_array);
Than you should be able to do something like this for the loadPartialTemplate function:
Code: [Select]
function loadPartialTemplate($template_name, $function, $parameters = array())
{
global $settings, $modSettings;

$contents = '';

if (!empty($template_name))
{
// Get the Theme Folder
if (!empty($settings['actual_theme_dir']) && $settings['actual_theme_dir'] != $settings['default_theme_dir'])
$theme_dir = $settings['actual_theme_dir'];
else
$theme_dir = $settings['default_theme_dir'];

$filename = $theme_dir . '/' . $template_name . '.partial.template.php';

if (file_exists($filename))
{
extract($GLOBALS);
ob_start();

include_once($filename);

if (!empty($function) && is_callable($function))
{
if (!empty($parameters) && is_array($parameters))
call_user_func_array($function, $parameters);
else
call_user_func($function);
}
$contents = ob_end_clean();
}
}
return $contents;
}

In the template file now, it would make sense to just echo out $context['my_partial_template']


In the Partial Template File, would look something like this in ./Themes/default/MyTemplate.partial.template.php

Code: [Select]
function MyFunction($arguments) {
    global $blah, $context, $txt, $modSettings;

    echo '<p>Hello World</p>';
}

Than $context['my_partial_template'] would be equal to <p>Hello World</p>

Could we please get something like this?  Because of the way you have SMF configured, it's impossible to do this within the Source file it seems, or maybe there's an error in my code somewhere.

In any case, I find myself fighting more and more with the SMF code, rather than working with it!  This is just a basic thought of possibly a greater functionality of Theming/Modding for SMF altogether.  Ofcourse, we'd want to handle this in a cleaner approach, but this is the basic concept that I think is important.
« Last Edit: November 08, 2015, 05:41:56 AM by SoLoGHoST »

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,524
  • Gender: Male
    • Kindred-999 on GitHub
Re: loadPartialTemplate function Please?
« Reply #1 on: November 08, 2015, 08:17:55 AM »
maybe I am missing something, but I don't understand your use-case example...

however, if I understand what you are actually asking -- I don't think it is really possible without re-writing the entire SMF templating system
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 14,972
  • Kaizoku Jotei
    • SMF mods
Re: loadPartialTemplate function Please?
« Reply #2 on: November 08, 2015, 11:12:01 AM »
Code: [Select]
function myFunction()
{
global $context;

loadTemplate('myTemplate');

$context['my_partial_template'] = template_myPartialTemplate($arguments);
}


Code: [Select]
function template_myPartialTemplate($arguments)
{

$return = 'hello world!';

return $return;
}

Real world example: 
https://github.com/MissAllSunday/ActivityBar/blob/master/Sources/ActivityBar.php#L91
https://github.com/MissAllSunday/ActivityBar/blob/master/Themes/default/ActivityBar.template.php#L29

There are a couple of procedural mods out there that also uses returned values from a template function. Actually, all HTML should be stored in template/views functions, it helps keeping logic completely separated from the presentation.


 I'm sorry but not really knowing how to handle functions and their return values doesn't really count towards a bug, flaw, feature request or otherwise a limitation within SMF.

Edit, typos.
« Last Edit: November 08, 2015, 12:19:37 PM by Suki »
I'm not a criminal.
I'm not a rapist.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,524
  • Gender: Male
    • Kindred-999 on GitHub
Re: loadPartialTemplate function Please?
« Reply #3 on: November 08, 2015, 11:52:58 AM »
Right, so I am incorrect and it is actually very simple to do...  and ^^^  would be why I am not a developer. :)
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #4 on: November 08, 2015, 03:06:25 PM »
I'm sorry but not really knowing how to handle functions and their return values doesn't really count towards a bug, flaw, feature request or otherwise a limitation within SMF.

Seriously?

My problem is that, for each additional theme that gets added, the function needs to be added to that template file in that theme in order for the mod to work.  My Feature Request is that we make it something that is related to the Customization (not the actual theme), but loads, kinda like hooks do for Source files, but, instead for themes.

The dreaded task of making your mod work in all themes, is not something that the Mod author should be responsible for, by adding template files to that theme.  Excluding the functionality of a Customization to SMF, simply because the template file is in that theme, but the function isn't, is not acceptable either.  It might make sense to separate the templating of Modifications from Themes altogether.

I can not simply loadTheme('MyTemplate') within a theme template that is already loaded.  I am only able to load a function within that template file that is already loaded, that does not exist within that custom theme.  This is the problem!

I will give you an example of this.

In wordpress, you can create plugins.  These plugins are not related to the Theme.  They have their own file that loads separate from the Themes functions.php file.  They have their own Backend Administration section that, also, loads separate from the theme.  There are filters, actions, meta, etc. that can be used to hook in whatever functionality that the plugin offers (kinda like SMF integration hooks, cept much more flexible), along with any templates/HTML that can be used within those filters, actions, etc..

Than 1 can simple call:
Code: [Select]
do_action('YourActionName');

And all the magic happens.  You can apply actions on top of already existing actions also.

What I am suggesting is nothing new, it has been done many times before, and allows much more flexibility and control (that is needed) than the integration hooks in SMF.

Sorry, my code example was not a good example of what I'm actually trying to get across in this topic.  I hope that it is clearer now?
« Last Edit: November 08, 2015, 03:40:54 PM by SoLoGHoST »

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
RE:add_integration_template
« Reply #5 on: November 08, 2015, 03:44:57 PM »
perhaps the title of this topic should be renamed to:  add_integration_template instead.  Which I believe would fulfill this feature request, if Theme templates were created with these functions in theme, starting with the default theme in SMF.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #6 on: November 08, 2015, 04:04:05 PM »
Actually, all HTML should be stored in template/views functions, it helps keeping logic completely separated from the presentation.

I am very sure that I could present you with many Source files and functions in SMF that echo html directly within the source file itself.  I am not wanting to get into the reasons why SMF choose to do this.  Please do not reply back with a justifiable reason for this.
« Last Edit: November 08, 2015, 04:27:45 PM by SoLoGHoST »

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,524
  • Gender: Male
    • Kindred-999 on GitHub
Re: loadPartialTemplate function Please?
« Reply #7 on: November 08, 2015, 04:19:49 PM »
You do realize that you do not have to add template files to every theme?   Add them to the default theme and every other theme will automatically use them
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #8 on: November 08, 2015, 04:28:54 PM »
Yes, I'm well aware of this Kindred.  However, if the Custom Theme has that template file in it, but not that function, the Mod will not work in SMF, for that theme.  This is the problem.

Not to mention the template function insertion point of another function.

Storing the variable $context['mytemplatefunction'] = call_other_function_inside_template($args);

Still leaves you with the needed echo of $context['mytemplatefunction'] somewhere within the template file itself.

Also, if a template file is already loaded, for example:  loadTemplate('Display');

You can't load another template file, so it's not possible!  I would need to load a function from a template file within an integration function that is called from Display.php, after loadTemplate('Display') has been called.  It will give error, because you can not load 2 different template files from within the same function that is loading 1 already, prior to the call to the integration hook.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,524
  • Gender: Male
    • Kindred-999 on GitHub
Re: loadPartialTemplate function Please?
« Reply #9 on: November 08, 2015, 04:31:42 PM »
True...   That is why we encourage the use of hooks...

But also, 2.0 and 2.1 both attempt to install mod changes into all custom themes at the time of. Do installtion, so, if the theme has a template I'm it, 2.0 and 2.1 will add your new function into that template...    But there are sufficient existing hooks, especially in 2.1 that your suggestion should not Be necessary.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Bloc

  • Jr. Member
  • **
  • Posts: 391
  • Gender: Male
    • bloc67 on GitHub
    • bjornhkristiansen.com
Re: loadPartialTemplate function Please?
« Reply #10 on: November 08, 2015, 04:34:19 PM »
Not that many themes ships with copies of different mod's templates - for the most part they reside only in the default theme.

But yes, its a problem as such - but more for theme authors that want to modify those templates. The solution is usually: don't.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #11 on: November 08, 2015, 04:40:41 PM »
So, here's my situation.

I need to integrate a function from a hook that adds values to variables, that gets loaded in a template, and need to grab all global variables from that template file after everything has been set in the source file function, without editing the template file itself... in order to output html for a modification.

Is this possible with SMF?  No, not currently that I can see.

Is it possible with other Website solutions?  Yes, Umbraco, Wordpress, and others....

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 14,972
  • Kaizoku Jotei
    • SMF mods
Re: loadPartialTemplate function Please?
« Reply #12 on: November 08, 2015, 04:48:37 PM »
SoLoGHoST, I'm pretty sure whatever "problem" you have with using the SMF template system can be easily solved, perhaps instead of always having this "confrontational" attitude you could simple ask nicely, someone will reply, you will complete your mod already and everyone will be happily ever after...


So perhaps, and just perhaps, instead of passive-aggressive attacking and glorifying other (equally crappy template engine) why don't you just cut to the chase, tell us exactly what you want to achieve and be done with it?


So, here's my situation.

I need to integrate a function from a hook that gets loaded in a template, and grabs all global variables from that template file, without editing the template file itself.


That doesn't add much, need real code, real working code to fully understand what you want.

Every template in SMF gets called by a source file so chances are there is a hook in 2.1 that will do what you want  and I need to reiterate, template files aren't the best place for code logic and there should be a better way to handle this but of course you need to fully explain what you want to do.
I'm not a criminal.
I'm not a rapist.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #13 on: November 08, 2015, 04:51:48 PM »
I edited the post to explain it better.  Hopefully, it explains what I am trying to do.  I wonder if integrate_pre_include integration function would help here?

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 14,972
  • Kaizoku Jotei
    • SMF mods
Re: loadPartialTemplate function Please?
« Reply #14 on: November 08, 2015, 04:59:38 PM »
No, like I said, need real code to work with.  I can't give you a generic example because it simply won't be what you need

Don't explain the logic of it or how you think it should be done, post whatever code you have and explain what your mod is suppose to do.
I'm not a criminal.
I'm not a rapist.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #15 on: November 08, 2015, 05:01:11 PM »
For example, in Display.php
Code: [Select]
call_integration_hook('integrate_prepare_display_context', array(&$output, &$message));

I would like to load a template file to be echo'd out within this hook, but in a certain spot within template_single_post() function.  Is this possible?

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 14,972
  • Kaizoku Jotei
    • SMF mods
Re: loadPartialTemplate function Please?
« Reply #16 on: November 08, 2015, 05:04:29 PM »
Seriously, can you please post the code you are working with, please.

Try and avoid posting what you think it should be done or how it should be done, just post whatever code you have, thats it.
I'm not a criminal.
I'm not a rapist.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #17 on: November 08, 2015, 05:14:37 PM »
Ok, give me a few to separate all of the unneccessay stuff in code.  And thanks

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #18 on: November 08, 2015, 05:51:25 PM »
Ok, well, I am a moron!
After some digging now, am able to do this using ob_get_contents() argg, not ob_end_clean();
Anyways, still left with the variable injection into the template file.  Sorry for all of this.

I'm still faced with the issue of editing the template file however.  I will post up code BTW.
« Last Edit: November 08, 2015, 06:10:12 PM by SoLoGHoST »

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #19 on: November 08, 2015, 06:14:11 PM »
Here is the code that hooks into the prepareDisplayContext integration_function:

Code: [Select]
function prpro_integrate_prepare_display_context(&$output, &$message)
{
global $topic, $context, $options, $user_info, $settings, $txt, $scripturl, $boardurl, $modSettings, $ratings, $ratings_enabled;

$output = array_merge(array(
'rating' => loadRatingsInfo($message['id_msg'], !empty($message['ratings_enabled']) ? $message['ratings_enabled'] : 0, !empty($message['id_last_rating']) ? $message['id_last_rating'] : 0, $message['id_member'], !empty($context['topicinfo']['is_ratings']) ? $context['topicinfo']['is_ratings'] : 0),
'reached_ratings_limit' => !empty($modSettings['post_ratings_limit_count']) && (intval($message['total_ratings']) >= intval($modSettings['post_ratings_limit_count'])),
'can_postratings_rate' => allowedTo('postratings_rate') && !empty($message['ratings_enabled']) && (empty($modSettings['post_ratings_own_post_rating']) ? $user_info['id'] != $message['id_member'] : true),
'has_ratings' => !empty($message['total_ratings']),
'topic_id' => $topic,
'not_your_post' => empty($modSettings['post_ratings_own_post_rating']) ? $user_info['id'] != $message['id_member'] : true,
'can_enable_disable_postratings' => allowedTo('ratings_enable_post_any') || (allowedTo('ratings_enable_post_own') && $user_info['id'] == $message['id_member']),
'ratings_enabled' => !empty($message['ratings_enabled']),
'first_enabled' => (empty($modSettings['post_ratings_type']) && empty($modSettings['post_ratings_first_post'])) && $message['id_msg'] == $context['topicinfo']['id_first_msg'] ? false : true,
'topic_enabled' => $ratings_enabled && !empty($context['topicinfo']['is_ratings']),
'post_rating_stars' => GetPostRating('stars', $message['id_msg'], !empty($message['total_ratings']) ? $message['total_ratings'] : 0, !empty($message['rating']) ? $message['rating'] : 0),
'post_rating_num' => GetPostRating('text', $message['id_msg'], !empty($message['total_ratings']) ? $message['total_ratings'] : 0, !empty($message['rating']) ? $message['rating'] : 0),
'post_rating_totals' => !empty($message['total_ratings']) ? (int) $message['total_ratings'] : 0
), $output);

include_once($settings['default_theme_dir'] . '/PostRatingsPartials.template.php');

ob_start();
template_postratings_message_header_style($output);
$output['post_ratings_header_style'][$message['id_msg']] = ob_get_contents();
ob_end_clean();
}

Now in ./Themes/default/PostRatingsPartials.template.php I have this:

Code: [Select]
// Post Ratings Header Style Template Function
function template_postratings_message_header_style($message)
{
global $context, $settings, $options, $txt, $scripturl, $modSettings, $boardurl, $user_info;

$view_ratings = allowedTo('postratings_view_user');

if (!empty($modSettings['post_ratings_layout_style']))
{
// Header - is it enabled or not??
if ($message['ratings_enabled'] && $message['topic_enabled'] && $message['first_enabled'] && allowedTo('postratings_view'))
{
echo '
<div class="title_bar">
<h3 class="titlebg" style="font-weight: normal;">';

$view_ratings =  $view_ratings && !empty($message['ratings_enabled']) && $message['topic_enabled'];

if ($message['has_ratings'])
{
if (!empty($message['post_rating_totals']))
{
if (!empty($modSettings['post_ratings_show_quantity']))
echo '
<div class="floatright smalltext">', ($view_ratings ? '<a href="' . $scripturl . '?action=postratings;sa=view;board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . ';msg=' . $message['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return reqWin(this.href);">' : ''), $txt['postratings_count1'], ' <strong>', $message['post_rating_totals'], '</strong> ', ($message['post_rating_totals'] < 2 ? $txt['postratings_count2'] : $txt['postratings_count3']), ($view_ratings ? '</a>' : ''), '</div>';
else
if ($view_ratings)
echo '
<div class="floatright smalltext"><a href="', $scripturl, '?action=postratings;sa=view;board=', $context['current_board'], ';topic=', $context['current_topic'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" onclick="return reqWin(this.href);">', $txt['post_ratings_view_ratings'], '</a></div>';
}

$textOut = 'post_ratings_text' . $message['post_rating_num'];

echo $message['post_rating_stars'] . '<table cellspacing="0" cellpadding="0" border="0" class="floatleft"><tr><td align="left" valign="middle">' . parse_bbc(stripslashes($modSettings[$textOut])) . '</td></tr></table>';
}
else
echo parse_bbc(stripslashes($modSettings['post_ratings_not_rated']));

echo '
</h3></div>';
}
}
}

And now in Display.template.php, all that is needed, is this, within the template_single_post function:

Code: [Select]
echo $message['post_ratings_header_style'][$message['id']];

Which greatly reduces the code inside the template and handles it inside my own template file PostRatingsPartials.template.php

The problem still exists that I need to add to the Display.template.php file in order for it to show, however.  If you know of a better way to do this without editing the Display.template.php file, that would be most appreciated.  If this is not possible any other, cleaner way, than I would be leaning towards a feature request for the ability to do this somehow (for mod developers).

marg edit: fixed minor issue with code tags
« Last Edit: November 08, 2015, 07:13:50 PM by SoLoGHoST »

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #20 on: November 08, 2015, 10:49:57 PM »
1 quick way I see to solve this, is to use php comments within the function template files as insertion points, for either before or after, and tell Theme authors to leave comments intact, or move them to the appropriate place.  Which I don't see why Theme authors would want to remove comments anyhow, since all template files are stuck coming from the Source file anyways.  Than they could even add more comments within the function that could also act like insertion points.  If comment doesn't exist, Mod Template doesn't get inserted.  This gives another option for Mods to have their own templates that can work in all themes.

Ofcourse, this is probably too ugly for SMF to consider using comments within template file functions for insertion points of other templates in Mods, but it's the most logical way to go IMO.  It wouldn't be the first time php comments were used for something useful in a php application, other than being just a php comment.

The benefits of being able to supply your own template file, for any file that gets loaded in SMF (or even another MOD/Theme) via loadTemplate, outway the ugliness of using comments as hooks for this, TBH.  Removing HTML from a template, would be simply removing the file, instead of touching the actual template file instead.  Nothing cleaner than that.  Hell, comments can also have keys associated with them to make it cleaner.

If this is handled in code, instead of writing to the actual template file, I can see less errors with installs, better handling of templates, and Theme Authors not needing to account for Mods when coding their themes as much as they do now, I'm sure.  I'm sure there are even more benefits to hooking into a template file than I have listed.  I would say, it might even be a good idea to provide a priority integer for the function hook that does this, to load the mod template in the priority defined by the hook call.
« Last Edit: November 08, 2015, 11:22:36 PM by SoLoGHoST »

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #21 on: November 09, 2015, 12:15:47 AM »
Nevermind about comments.  Prob not possible using that approach anyways.  Just thinking out loud here...

Just entertaining myself on that thought, kinda flawed and incomplete tho:

Code: [Select]
$tokens = token_get_all(file_get_contents('C:\wamp\www\smf2.1\Themes\default\Display.template.php'));
$comments = array();
foreach($tokens as $token) {
    if($token[0] == T_COMMENT || $token[0] == T_DOC_COMMENT) {
        $comments[] = $token[1];
    }
}

foreach($comments as $comment)
{
    if (strpos($comment, '// Show the message anchor and a "new" anchor if this message is new.') !== FALSE)
template_function($comment);
}

function template_function($comment) {

echo 'Hello World
<p>The comment = ' . $comment . '</p>';

}

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 14,972
  • Kaizoku Jotei
    • SMF mods
Re: loadPartialTemplate function Please?
« Reply #22 on: November 09, 2015, 09:09:15 AM »
Calling ob_start and ob_end on your function its not a good idea, your function will be executed on each and every message been displayed so calling those ob functions 10, 15 or 20 times per page its going to have some severe server issues.

There is no need to do all the stuff you are doing, on 2.1 the custom profile system has been expended to cover more places and to be usable by mod authors outside merely adding more custom profile fields.

There is a placeholder just below the message, you could use that to inject your html code, it will be totally compatible with whatever theme and you will avoid file edits.

Take a look at the links I previously gave:

https://github.com/MissAllSunday/ActivityBar/blob/master/Sources/ActivityBar.php#L91
https://github.com/MissAllSunday/ActivityBar/blob/master/Themes/default/ActivityBar.template.php#L29

another example of a mod using that system:

https://github.com/MissAllSunday/Breeze/blob/develop/Sources/Breeze/Breeze.php#L740
https://github.com/MissAllSunday/Breeze/blob/develop/Sources/Breeze/BreezeMood.php#L153


Your mod will be much easier to deploy since you don't have to worry about personal messages and the profile page, those pages also shows the custom fields but your mod is solely focused on messages instead of users, thus you only need to use the hook you are already using (integrate_prepare_display_context).

Now, if your mod's html doesn't fit inside the li tag or you don't want to use that approach then you can still made an edit on Display.template.php files.

There is nothing wrong with doing a template edit providing you do it in the correct place and with minimal intermission, if all your logic is properly handle in your source file then you don't need to worry about other mods messing with your code  and by keeping all the style and css to the theme author you don't have to worry about theme compatibility either.

Just because the system lets you replace an entire file with some new code doesn't mean that you will do it, properly placed and minimal presentation-only edits, combined with proper code architecture and a complete separation of logic and presentation really does help keeping the annoying support requests down, just take a look at my mod's support request, I don't get any support request to "make my mod compatible with X theme". All support request I receive are about actual flaws in the mod or custom enhancements. This includes compatibility too.
I'm not a criminal.
I'm not a rapist.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #23 on: November 09, 2015, 12:30:54 PM »
Ok, no problem.  I think I understand what you are saying if I read between the lines.  Seems your responses are in code also.  Basically what you are saying is this is not a request that SMF will do.  Use the template file, and SMF will not add any hooks into templates to help process this better/cleaner.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,524
  • Gender: Male
    • Kindred-999 on GitHub
Re: loadPartialTemplate function Please?
« Reply #24 on: November 09, 2015, 12:52:14 PM »
almost.... without your twist on the statement....

there are better ways to do the things that you seem to want to do - which do not involve editing the template or template system. Using hooks and SOURCE files instead of direct editing templates is one of those better ways. Since a better way exists, we have no plans to further complicate things by adding such additional functions into the template system.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 14,972
  • Kaizoku Jotei
    • SMF mods
Re: loadPartialTemplate function Please?
« Reply #25 on: November 09, 2015, 01:23:27 PM »
Ok, no problem.  I think I understand what you are saying

Huh, no you clearly not. This whole topic fully demonstrates you haven't payed any attention to any of what I said and instead keep on focusing on your "my way or the highway" attitude and pretty much you just read what you want to read. No point in keeping up responding anymore, even if its just to correct some blatantly wrong assumptions about SMF.
I'm not a criminal.
I'm not a rapist.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #26 on: November 10, 2015, 01:37:08 AM »
Ok, thanks for proving me correct.  I think I lied in last statement when I said, "The People are Great".  I think the people is the main reason why I quit customizing for SMF.  It's people like you Suki that adds nothing but ignorance to topics, and pushes people away.  I don't even care what you guys do, I don't want it my way.

I could care less what way it gets done.  Do whatever you want.  I only make suggestion.

Inflammatory comment removed.  There's no need for that - Iris.
« Last Edit: November 10, 2015, 05:14:36 AM by Irisado »

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,269
  • Gender: Male
  • Cat: Destroy!
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: loadPartialTemplate function Please?
« Reply #27 on: November 10, 2015, 06:12:42 PM »
Looking at your code, you should

- remove the output buffering
- assign markup to a variable and return it
- edit the display template to inject your line

Quote
Seems your responses are in code
No, her replies are not in binary.

Quote
Basically what you are saying is this is not a request that SMF will do
ignoring the confusion oveer the name (SM vs SMF), this is possible usisng verry hackish code.
Try not to become a man of success, but rather try to become a man of value.
- Albert Einstein

Offline 青山 素子

  • Server Team
  • SMF Super Hero
  • *
  • Posts: 16,999
  • 戦場ヶ原、蕩れ!
    • srvrguy on GitHub
    • @motokochan on Twitter
    • Nekomusume Moe
Re: loadPartialTemplate function Please?
« Reply #28 on: November 10, 2015, 09:50:51 PM »
At the risk of piling on, the issue is that when doing proper coding, you shouldn't stick a lot of logic in the template (view). You should only have the minimal logic needed to display values. This will make your code less intrusive, better contained, and also much easier to update when SMF updates.
Motoko-chan
Director, Simple Machines

Just because it's pouring down doesn't mean we're gonna drown. There's a time when all you can say is let it rain - Mat Kearney (Let It Rain)

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #29 on: August 07, 2016, 07:34:24 PM »
Hey, everyone, sorry for my replies.  Have been going through a lot of stuff in my life during all of that and well, just reading over my reactions to comments in here, I see that I was acting very wrong and stubborn.  Just wanted to apologize to everyone, but I also want to say that SMF does need better theme customization for Modifications (Not theme developers).  But I think this is a restriction due to the way the Core of SMF was built, which I believe would make sense to change.

Simply was asking for a way to change the look of SMF completely within a Modification without touching the default template files, which is very possible to do in other systems (e.g. Wordpress).  I have been working in other CMS's and, while SMF is a great forum software, and have had a lot of fun coding for it in the past, it doesn't have the power of flexibility that it should have to make it even greater.  But that is, I guess, what a Forum is, and you've all made a great forum software, but that's all it will ever be.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,169
    • Arantor on GitHub
Re: loadPartialTemplate function Please?
« Reply #30 on: August 08, 2016, 01:54:35 AM »
SMF's interface is massively more complex than WP's because out of the box it does a whole lot more.

Still can't see what you're actually asking for though, beyond breaking templates up a bit.

Then again you are talking to a guy who ports WP themes to SMF...
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen your role in this, and now I must choose mine.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #31 on: August 16, 2016, 01:22:39 AM »
So, in Wordpress, you can create a plugin.  The plugin can have it's own templating structure, and the templating structure can call on built-in functions such as add_filter and add_action that can further extend your plugin.  By further extending your plugin, I mean, that someone can create another plugin that relies on your plugin, and extends it for whatever filters you have installed on your plugin.  As a bonus, if your plugin calls upon any of the thousands of wordpress built-in filters/hooks, this can be used by the other plugin to modify it (with priority) and pinpoint the filters and/or actions used by the other plugin.  This creates sort of a cascading affect of PHP, which kinda makes coding a bit more flexible and fun.  Converting a WP Theme, would mean that you would need to open up the functions.php file within a WP Theme and you would run into trouble with filters/actions possibly.  One such action could be the wp_enqueue_script action, admin_enqueue_script or even wp_head, wp_admin_init, wp_init.  Themes for WP can do much more than change the appearance of the front-end, they can also modify the backend.  I know SMF provides a way to add menu's etc., but it's not exactly the same.  There are Widgets also in Wordpress that can be bundled with Themes.  I would think that your conversions of Wordpress Themes are not exactly a 1-to-1 conversion.  More likely an appearance only conversion.  SMF just doesn't provide the means to edit the default templates in SMF (without editing those templates directly, or creating a new theme, which would require creating your own code entirely in the Source to accommodate your theme).  SMF doesn't really provide the flexibility of re-using their built-in functions for other purposes other than what the default theme really provides.  There really isn't a flexibility with SMF built-in functions that Wordpress has available with filters and actions.  Take a look at Woocommerce Plugin for Wordpress, and how many different extensions there are for it.

I haven't used the newest version of SMF yet, so maybe I am not entirely correct in what I'm saying here, but from past experiences...

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,169
    • Arantor on GitHub
Re: loadPartialTemplate function Please?
« Reply #32 on: August 16, 2016, 02:58:58 AM »
SimpleDesk was doing the whole plugin of a plugin thing five years ago. With hooks for no file editing, for good measure.

The problem in SMF is that the current templates are too monolithic and can't individually be replaced out. Other than that everything you're talking about has been doable in SMf for years, just no one wanted to do it.

Theming SMF is a larger job than theming WP because you don't have a simple semi generic interface to serve, and plenty of plugins foul up on different themes. I work with a design agency every day and every day I hear new complaints about themes and WP...
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen your role in this, and now I must choose mine.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #33 on: August 16, 2016, 04:55:15 PM »
AMEN, you said it just right Arantor!  Glad to see you still around here, as much as we conflict, sometimes we also see eye to eye ;)  Cheers, buddy!  TBH, I never looked at your Simple Desk code, but I knew if it was built from Arantor it was a fine piece of software.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,524
  • Gender: Male
    • Kindred-999 on GitHub
Re: loadPartialTemplate function Please?
« Reply #34 on: August 16, 2016, 06:39:33 PM »
Actually, a fe wof Bloc's themes allowed changing the placement of some of the blocks by choice...
banner, menu, news

several of the portals allow moving blocks around...

so, it is possible, even in the SMF theming system
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #35 on: August 18, 2016, 09:39:00 PM »
Hello Kindred, nice to see you still around.  Thanks for your input, but that's not exactly what we are saying here.  Basically there needs to be some easier way to manipulate the content in the themes that come bundled with SMF (and, also, any theme that gets installed).  Creating new theme files is not a good alternative, because it does not change the default file(s) (Theme that's installed).  Creating your own theme, now makes it more work.  There simply needs to be an easier way to do this.  I mean, there is much easier ways out there already with other platforms.  This is why my initial thought was to integrate Theme hooks with SMF, which I still think would be a good idea to hook your code into any theme automatically.  Adding functionality within a theme without editing the files of that theme.  I mean, I never did like doing theme edits to the Default theme and the Core theme for my mods, only to find out that the next version of SMF added a tab or a space where I did my replace/after/before at.  Anyways, was just a thought...

Quite frankly, I feel like doing edits to theme files is a bit sloppy nowadays.  It's kinda like building a website with HTML only where you have to do a million and 1 edits to a million and 1 files...  I feel like this can be handled better, that's all.  Cheers :)
« Last Edit: August 18, 2016, 09:49:24 PM by SoLoGHoST »

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #36 on: August 18, 2016, 10:42:19 PM »
Maybe SMF does not want to allow something like this because they want to keep template and source separated, but this does not have to be the case, and it can still be handled in a very clean and productive way...

For Example:

Wordpress does it a few different ways, but wordpress has built-in functions for allowing this also, with any plugin/theme, which SMF does not.

Such functions are as follows:

Filters:  Allows the content/variable to be changed by any plugin... by passing in the first parameter to the filter function with priority...

apply_filters, add_filter, remove_filter, has_filter

Plugins can than do something like this:
Code: [Select]
echo apply_filters('my_filter_that_can_be_modified_by_any_theme', 'Default Value');

Now it will echo 'Default Value' if no filters exist that change this, otherwise, if the filter exists, it can be overridden...
Example:
Code: [Select]
add_filter('my_filter_that_can_be_modified_by_any_theme', 'another_function', 10, 1);
where 10 = priority, and 1 = parameters that get passed into the function_name.  Than anything (theme or plugin) can now manipulate the filter, like so:
Code: [Select]
function another_function($echo) {
   return 'Something Different'; // This will now replace 'Default Value' in that theme/plugin
}

Actions:  This is geared more towards simply outputting html for the most part.  This is not really a means to manipulate the original content, as it doesn't really get called to return anything...  For example:

add_action, do_action, has_action
Code: [Select]
if (has_action('my_plugin_action'))
    do_action('my_plugin_action', $param1, $param2);
And in the main plugin/theme file:
Code: [Select]
add_action('my_plugin_action', 'my_function', 10, 2);

function my_function($param1, $param2)
{
    echo '<div>Here is some content</div>';
}

Anyways, those are 2 examples.  The Wordpress Themes would than have do_action() in multiple spots where actions can be overridden, and apply_filters() in other spots where variables, etc. can be overridden.  If the default theme was built in such a way, other themes can mirror it and SMF I think would be a more productive forum platform, that can be made into something much bigger than what it is now.  Anyways, I'm just passing on what I know... do with it what you want.  Don't take other code, but make it something unique to SMF possibly?  It's the meaning behind the code that's important here.  SMF has done an amazing job already with the hooks in Source Files, but there is very little to no support to tie into Themes, and there needs to be IMO.
« Last Edit: August 18, 2016, 10:53:11 PM by SoLoGHoST »

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,524
  • Gender: Male
    • Kindred-999 on GitHub
Re: loadPartialTemplate function Please?
« Reply #37 on: August 18, 2016, 11:07:26 PM »
However... Wordpress pretty much sucks.  So comparing simple machines forum template design to Wordpress design is a poor choice.

We have worked very hard to separate functions from display and going backwards if not going to happen.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #38 on: August 19, 2016, 12:20:22 AM »
Ok, to each their own.  I'm not trying to push this topic on anyone.  Just thought I didn't explain myself good enough last time.  Wordpress does not suck, but that is your opinion.  And I'm assuming that you are making an opinion based on Experience?  My opinion is Drupal actually sucks as a CMS, cause it's unstable, and my experience with it was terrible.  SMF is a good software, but can be tough to work with because it being too STRICT on certain aspects that it need to be LOOSE on for a site to be flexible and valuable.  Developers will recommend the flexible choice with the most room for expansion to their Customers.

On another note:  I feel like I am constantly missing my target audience here.  The target audience I hope to achieve with my replies in this topic are open-minded individuals with the ability to understand the meaning of an analogy, and not take it so literal.  To say that is a step backwards, when over 74 million sites are depending on Wordpress and 29,000+ WordPress Plugins exist, 46 Million+ Downloads, over 18% of all sites on the web powered by Wordpress, well... they must be doing something right (And these are statistics from 3 years ago).  I'm sure you have nothing but good things to say about SMF, and that's all good, but there is an EVEN BIGGER picture.  Nuff Said.
« Last Edit: August 19, 2016, 12:47:19 AM by SoLoGHoST »

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 67,169
    • Arantor on GitHub
Re: loadPartialTemplate function Please?
« Reply #39 on: August 19, 2016, 12:46:34 AM »
And suddenly your argument ceases to make sense.

WordPress is better because more people use it? Sure more people use it, it's not a tool for serving a specific technical need. You're comparing it to SMF like you could compare a screwdriver to a plane (the woodworking kind) and go "more people use screwdrivers", which they do because it is a general purpose tool... Wordpress is a general purpose tool, SMF is not, it is therefore shocking that less people use SMF. SHOCKING.
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen your role in this, and now I must choose mine.

Offline nend

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,755
  • 2 deep n2 the code
    • sicommnend on GitHub
    • SIComm.us
Re: loadPartialTemplate function Please?
« Reply #40 on: August 19, 2016, 12:47:25 AM »
Been playing around with a similar idea with function hijacking. When a function is called passed vars can be modified or the function replaced by another with integration hooks. This could be applied to themes, however it's no magic bullet.

It isn't SMF will not change, it is change takes time.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #41 on: August 19, 2016, 12:54:51 AM »
I'm not trying to get into a debate on whether or not I am comparing SMF to Wordpress, because I simply am not trying to do this.  I only provided an example of how Wordpress handles hooking functions.  I can see that it is pointless, this conversation, yes.  I might as well talk a different language.  Cheers :)

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #42 on: August 19, 2016, 12:58:13 AM »
@nend, yes, I showed an example of this in earlier post with the integrate_prepare_display_context hook.  The thing I would like to see here, is ability to change HTML, not so much variables.  Although variable changing would be nice also, but that is already pretty much possible, since $context is the main variable for templates and can be modified mostly in Source files.  Basically, I just would like to be able to hook in my own partial templates, like partial HTML inside of the template, without editing the template.

I suppose it might help if SMF did something like this inside of their templates:

Code: [Select]
if ( ! function_exists( 'template_main' ) )
{
    function template_main() {
        // All template code in here...
    }
}

Than maybe we could override these functions individually with our own...  I think if they were to do this with more functions, we can hook our own in another template to overwrite parts of HTML.  Possibly a start on this?  Haven't worked with SMF in awhile, so a bit out of practice here, but if they loosened up their templates a bit and used that code where it can actually work, than perhaps it might be a great start to editing Themes that are already installed...

Thoughts?
« Last Edit: August 19, 2016, 01:13:44 AM by SoLoGHoST »

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 14,972
  • Kaizoku Jotei
    • SMF mods
Re: loadPartialTemplate function Please?
« Reply #43 on: August 19, 2016, 09:49:01 AM »
Thats already possible. You can overwrite functions in PHP.  Theres also the layer system, you can CRUD any template and subtemplate layers.

And no, the way wordpress does stuff cannot be applied to SMF, WP and SMF are two different things.
I'm not a criminal.
I'm not a rapist.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 54,524
  • Gender: Male
    • Kindred-999 on GitHub
Re: loadPartialTemplate function Please?
« Reply #44 on: August 19, 2016, 10:54:29 AM »
WordPress. I've been working with it for years and I absolutely hate using it for anything other than a very basic blog site. I actually agree with you regarding Drupal but not for the same reasons. Drupal has issues burying div inside div inside div so that modifying any css in their template is nearly impossible.

And arantor hit the nail on the head... WordPress is not good just because people use it...
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #45 on: August 19, 2016, 12:43:19 PM »
Thats already possible. You can overwrite functions in PHP.  Theres also the layer system, you can CRUD any template and subtemplate layers.

Can you provide minor examples of this perhaps?  If you are referring to override_function, than that requires APD PECL extension. Maybe this is 1 of the reasons why SMF should go OOP?  Than we can use Interface to accommodate this better.
« Last Edit: August 19, 2016, 01:01:29 PM by SoLoGHoST »

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,269
  • Gender: Male
  • Cat: Destroy!
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: loadPartialTemplate function Please?
« Reply #46 on: August 19, 2016, 07:03:03 PM »
Complete template override? Easy. I have some code I wrote several years ago to do this very thing:

Code: [Select]
function template_init()
{
add_integration_function('integrate_menu_buttons', 'fixSubTemplates', false);
}

function fixSubTemplates()
{
global $context;

$new_sub_template = empty($context['sub_template']) ? 'main_override' : $context['sub_template'] . '_override';

if (is_callable('template_' . $new_sub_template))
$context['sub_template'] = $new_sub_template;
}

The hook should be late enough in the runtime where you know the templates will have been already loaded, otherwise the overrides won't work.
Try not to become a man of success, but rather try to become a man of value.
- Albert Einstein

Offline nend

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 1,755
  • 2 deep n2 the code
    • sicommnend on GitHub
    • SIComm.us
Re: loadPartialTemplate function Please?
« Reply #47 on: August 19, 2016, 10:27:02 PM »
@live627, nice, I didn't think of that.

Here's what I wrote a week or two ago.

Code: [Select]
$smcFunc += array(
'ufunc' => function ($func, $vars = null, $array = false)
{
// Allow hooking into functions to rewrite vars or send the data to another function instead.
call_integration_hook('integrate_before_func_'.$func, array(&$func,&$vars));
if (!empty($func))
$return = call_user_func_array($func, is_array($vars) && $array == true ? $vars : array(&$vars));
if (!empty($return)) {
// allow modifications of return data.
call_integration_hook('integrate_after_func_'.$func, array(&$return));
return $return;
} else
return false;
},
'load' => function ($path, $file, $type = 'generic')
{
// File hijacking, good for when you want to replace source files with others.
// Types source, theme, lang, generic
call_integration_hook('integrate_require_'.$type.'_'.$file, array(&$file));
require_once ($path.$file);
}
);

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #48 on: August 20, 2016, 01:42:21 AM »
Nice, but adding it to an integration called integrate_menu_buttons?  There should be built-in functionality for this that is obvious, not sneaky hacks.

In any case, thanks for sharing guys, but I feel like Suki was referring to overidding a function via PHP only, and I'd like to see an example of that without using the APD PECL extension.

Offline Suki

  • SMF Super Hero
  • *******
  • Posts: 14,972
  • Kaizoku Jotei
    • SMF mods
Re: loadPartialTemplate function Please?
« Reply #49 on: August 20, 2016, 11:32:26 AM »
Nice, but adding it to an integration called integrate_menu_buttons?  There should be built-in functionality for this that is obvious, not sneaky hacks.


Thats redundant. A hook is just a place in "space" and runtime, its name its just an indicator of where the hook is called, not its purpose.  A hook can be used in any purpose you want.

In any case, thanks for sharing guys, but I feel like Suki was referring to overidding a function via PHP only, and I'd like to see an example of that without using the APD PECL extension.

Nope.
I'm not a criminal.
I'm not a rapist.

Offline live627

  • Developer
  • SMF Hero
  • *
  • Posts: 5,269
  • Gender: Male
  • Cat: Destroy!
    • live627 on Facebook
    • live627 on GitHub
    • live627 on LinkedIn
    • @live627 on Twitter
    • livemods
Re: loadPartialTemplate function Please?
« Reply #50 on: August 20, 2016, 07:21:06 PM »
Quote
Nice, but adding it to an integration called integrate_menu_buttons?
Yeah. And  it works.

Hacks never look pretty.
Try not to become a man of success, but rather try to become a man of value.
- Albert Einstein

Offline SoLoGHoST

  • SMF Hero
  • ******
  • Posts: 1,792
  • Gender: Male
  • Real coders do not need to comment their code!
    • Dream Portal
Re: loadPartialTemplate function Please?
« Reply #51 on: August 20, 2016, 09:34:19 PM »
Ok, thanks again all for your attention on this topic.  I'm very lucky to have the attention that you folks give here.  Such great talented coders that have a huge impact on SMF and it's development makes me very proud to have the replies on this topic from such great minded individuals.  Thanks and I look forward to what SMF becomes in the future.  :)