Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Plugin hooks
« Reply #75, on April 1st, 2011, 12:31 PM »
Warning: this is a *very* technical post. It also spoils a lot of things about Wedge's internals, eheh.
Quote from Dragooon on March 31st, 2011, 05:31 PM
TBH manually positioning every hook in every bit of template is a very impractical practice, it may seem workable in theory but I don't see it actually working out. Hooks in actual workflow is a lot more sensible and practical thing.
I don't see your point...

Let's take this example. Edit Load.php, loadSubTemplate().

Code: [Select]
$theme_function = 'template_' . $sub_template_name;
if (function_exists($theme_function))
$theme_function();

Into this...

Code: [Select]
$theme_function = 'template_' . $sub_template_name;
$theme_function_override = $theme_function . '_override';
if (function_exists($theme_function_override))
$theme_function_override();
elseif (function_exists($theme_function))
$theme_function();

That basically allows us to load any kind of overriding template indicated by the styling (in settings.xml, let's say), and then we can completely override the existing function.
We could also have two other functions: $theme_function_before and $theme_function_after, which would be executed respectively before and after the target template function -- without preventing the original function from being run, allowing themers to insert data easily.
Of course, these functions could be added to each other (e.g. a mod adds a _before function to a template function, and the current function also overrides it -- let's just say themes always have priority over mods so their code is run first, then all mods in whatever order.)
Of course, it's not practical for very specific areas like adding buttons to a strip, but in these cases we always have proper hooks with the list of variables, so mods will use hooks for these, and for areas without a hook, they can use _before, _after and/or _override. Then our job is to simply split template functions into many smaller functions.

...Or we could just add template hooks here and there in important areas of the template, of course.
The solution I gave is just a quick one to allow themers to override any single function without us needing to add hooks everywhere.
Quote
The thing is, Tox-G adds a lot of possibilities otherwise which I consider to be quite hard doing with pure PHP without actually limiting a designer.
WeCSS also has the same features and limitations, somehow. Because it's preparsed, it gave me great freedom to develop it into an object-oriented version of CSS, and it made it so much simpler for me to manipulate objects with common parents, it's really impressive... However, it also puts an extra burden when it comes to inherited stylings -- if I want to restyle an object that is already parent to others, but I only want to restyle that particular object, I have to careful consider whether or not I'll specifically prevent inheritance for my rules. All in all, more power also means more complexity. Because most of the important objects in Wedge's CSS are linked to others through inheritance, themers will be required to learn how inheritance works, which is basically the whole point of having extra sample stylings that show how it works.

(And in that respect, I'm really glad I made Wine the main styling and pushed Warm to an inherited styling, because it shows how to... pretty much get rid of all the bells and whistles in Wine, so people don't have to worry about making designs that are too close to Wine. At this point, I could even rework Warm to make it even more removed from the Wine style. Something like WordPress's awful default themes.)
Quote
I haven't encountered a thing that I can't do with pure TOX-G. But to each it's own, PHP got its own advantages. One of my main motives of  advocating TOX-G is because of it's hookable nature,
Correct me if I'm wrong, but it's only hookable by splitting functions into many, right...? Or does it allow one to take the sub-template's HTML and manipulate it as a string before reinjecting it to Tox-G's parser? Which is the only way I can see for Tox-G to be superior to SMF/Wedge's current implementation...
Re: Plugin hooks
« Reply #76, on April 1st, 2011, 12:39 PM »
Quote from texasman1979 on April 1st, 2011, 03:39 AM
and i have a sig defined, but it doesnt appear to show up? does this custom version of smf yall are using require something that i dont know to set?
Actually, sigs only show up for members with at least 10 posts. This is to discourage spammers from posting here...

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
Re: Plugin hooks
« Reply #77, on April 1st, 2011, 12:59 PM »
Will you add a template hook at every place possible? Posts user info, post options, below one's sig, above post's title, above topic's title, below post's listing, below and above quick reply, quick reply itself, how about editing an existing template itself? Hooks are a lot more sensible on workflow itself, hence they work fine at controller and model stages but not at the view part.
The way it's meant to be

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Plugin hooks
« Reply #78, on April 1st, 2011, 01:06 PM »
Quote from Dragooon on April 1st, 2011, 12:59 PM
Will you add a template hook at every place possible?
As I said: automatic template hooks in every single sub-template (before and after), as well as manually added hooks in places that matter. We could also resume our work (well, Pete's work!) of splitting templates into many sub-templates. The work I did on rewriting the sub-template flow should help a lot. (Three different template layer systems instead of one, helper functions, and let's not forget that Pete originally thought of making it possible to have multiple sub-templates [1] which, what a shame, still isn't possible in SMF!!!)
Quote
Posts user info, post options, below one's sig, above post's title, above topic's title, below post's listing, below and above quick reply, quick reply itself, how about editing an existing template itself? Hooks are a lot more sensible on workflow itself, hence they work fine at controller and model stages but not at the view part.
Anything you want, really. We could discuss it in private if you'd like, or just keep doing it here. (Funny, this is technically the first development thread we're having in a public place...)

You didn't reply about Tox-G's exact abilities?
 1. As opposed to nesting multiple template layers.

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
Re: Plugin hooks
« Reply #79, on April 1st, 2011, 02:32 PM »
Wait, I did reply about TOX-G's exact abilities, what are you trying to ask? How it works or what advantages it has over PHP?

As far as TOX-G's functioning go :
1) Every template is defined in a XML like manner, you know the syntax. It is easier to follow then pure PHP and has some very nice little features and is actually quite easy to extend and adapt, one just needs to give a sitting with its code for a few hours and one can develop it further
2) Every template can be altered to add an overlay before or after it, I believe every template can also be replaced but I haven't experimented with this.
3) The template's files themselves are in a XML-esque manner which make sense for someone who don't know PHP but wants to do designing.
4) TOX-G parses the templates and caches them as PHP, so speed isn't really that much of a problem

All in all, yes it is possible to do the hook system by dividing the whole thing into very small templates and essentially this is what TOX-G does(But it is easier to do so).
Quote from Nao/Gilles on April 1st, 2011, 01:06 PM
Anything you want, really. We could discuss it in private if you'd like, or just keep doing it here. (Funny, this is technically the first development thread we're having in a public place...)
Its your choice, if you want you can move this to private boards.

texasman1979

  • Posts: 99
Re: Plugin hooks
« Reply #80, on April 1st, 2011, 03:05 PM »Last edited on April 7th, 2011, 04:55 AM by texasman1979
...
LOGIC is a FOUR letter word! :)


Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Plugin hooks
« Reply #81, on April 1st, 2011, 04:20 PM »
Please, texasman. If you want to be read -- make us want to read you. Right now you're talking about this "yall" man I've never heard about, and you apparently have a problem with your punctuation keys. That's okay for short blurbs, but long posts need quite some effort to read.

Are you asking for something anyway? I'm not sure... I can't bother to read your long posts. See what I mean?

texasman1979

  • Posts: 99
Re: Plugin hooks
« Reply #82, on April 1st, 2011, 04:26 PM »Last edited on April 7th, 2011, 04:55 AM by texasman1979
...

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Plugin hooks
« Reply #83, on April 1st, 2011, 04:27 PM »
Quote from Dragooon on April 1st, 2011, 02:32 PM
Wait, I did reply about TOX-G's exact abilities, what are you trying to ask? How it works or what advantages it has over PHP?
How it works.
Quote
As far as TOX-G's functioning go :
1) Every template is defined in a XML like manner, you know the syntax.
Yeah, although I'm trying not to think too much about it... I'm already having a hard time getting used to HTML5's lack of self-closers ;) (Well, I could have left them in, but I don't see the point in wasting bandwidth when it's valid either way.[1])
Quote
It is easier to follow then pure PHP
...Except for programmers...
Quote
2) Every template can be altered to add an overlay before or after it, I believe every template can also be replaced but I haven't experimented with this.
Okay, then that's in no way better than Wedge for this..? Given that I can easily add a before/after/override hook to any template function as demonstrated earlier?
Quote
3) The template's files themselves are in a XML-esque manner which make sense for someone who don't know PHP but wants to do designing.
If they don't know PHP at all, is there a reason for them to know about XML..?
And as far as I can remember, broken XML (even slightly broken!) means broken *everything*? Unless Unknown wrote a custom parser that accepts any errors in the XML output... And/or the actual XML is treated as HTML, in which case everywhere you put some actual XML for ToxG's use, it will still fail horribly... (Let's say you type < tmp:something >, will it be parsed correctly? I know I'm quite torn myself whether or not I should add support for loose whitespace in my styling blocks...)
 1. I'm serious when I say I did my best to compensate for jQuery's download size... And these guys are adding more kilobytes to it on every single release, what the fork >_<
Re: Plugin hooks
« Reply #84, on April 1st, 2011, 04:33 PM »
Quote from texasman1979 on April 1st, 2011, 04:26 PM
i am merely expressing an alternative way of looking at the hooks concept.
Why, have you looked into ours in the first place? (It's pretty close to SMF's so I should think so.)
Quote
and i use commas and periods dammit. lol
But what about single quotes and uppercase among others?
Quote
and yall = wedge, nao, and arantor
Yall is Wedge, Nao and Arantor? When did we start calling ourselves Yall?
Do you mind if I call you and your car "Zlipt"?
Quote
i guess you never been to texas.
I've never been to the Americas, period.
Quote
well you ought to. lol
I'm living in France. The number one touristic destination in the world. And it's a damn fine country.
Still, it's an international forum and I'm doing my best to speak an understandable English for everyone's benefit.
If you're in Texas, Zlipt, which last I heard was part of the United States of America, with English as primary language, why exactly aren't you speaking proper international/commercial/business English in here?

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
Re: Plugin hooks
« Reply #85, on April 1st, 2011, 04:37 PM »
The thing with the potential wedge template model you're talking about is that some work will also be needed on source sides of file as well, it won't be pure PHP. Not big of an advantage, I know.

XML(Or TOX for that matter) isn't more difficult to understand for programmers, it makes sense if you read it, seriously, give it a shot(10 minutes max), I'll give you some sample templates from my project if you want.
Quote
If they don't know PHP at all, is there a reason for them to know about XML..?
XML is a far more wide adaptation than PHP, more than that, it is easier to understand than PHP's syntax.
Quote
And as far as I can remember, broken XML (even slightly broken!) means broken *everything*? Unless Unknown wrote a custom parser that accepts any errors in the XML output... And/or the actual XML is treated as HTML, in which case everywhere you put some actual XML for ToxG's use, it will still fail horribly... (Let's say you type < tmp:something >, will it be parsed correctly? I know I'm quite torn myself whether or not I should add support for loose whitespace in my styling blocks...)
Unknown's syntax is based on XML, but it is not strict XML per se. TOX-G uses a custom parser and not any standard parser(It doesn't even need the most basic XML plugins for PHP). Hence the reason I could implement <we:if "expression">, < tpl:something > will not break things since it'll be treated like a string, <tpl:something> will since tpl is a reserved namespace and it is unclosed, but it'll give a nice error message! And yeah, TOX-G can self-close tags :P.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Plugin hooks
« Reply #86, on April 1st, 2011, 04:55 PM »
Quote from Dragooon on April 1st, 2011, 04:37 PM
XML(Or TOX for that matter) isn't more difficult to understand for programmers, it makes sense if you read it, seriously, give it a shot(10 minutes max), I'll give you some sample templates from my project if you want.
I already know ToxG's file structure, remember we discussed it several months ago already? At the time, everyone on the forum was excited at the idea of using ToxG for Wedge and I was quite alone saying I didn't see the point, then you guys spent a lot of time convincing me, I said okay as long as I'm not doing the conversion alone, Fustrate promised he'd convert one of the 'big templates' as an example, and then... Err... Well, said template never came, and the topic was buried ;)

Basically, what killed implementation is that it didn't have the ability to run ToxG templates alongside SMF templates (which would have been helpful because I keep modifying the templates so I couldn't stand stopping everything for several weeks), and/or no one stepped up to do the conversion work for me. I'm all for moving forward but I also have to draw the line sometimes -- there are only so many things I can do in a day. And my to-do-list is far from emptying itself faster than I can fill it up...
Quote
XML is a far more wide adaptation than PHP, more than that, it is easier to understand than PHP's syntax.
XML: <tpl:print="hello world" />
PHP: <?="hello world" ?>
Or something like that ;)
(Okay, I'm cheating with shortcuts but...)
Quote
Unknown's syntax is based on XML, but it is not strict XML per se. TOX-G uses a custom parser and not any standard parser(It doesn't even need the most basic XML plugins for PHP).
Yeah... They all suck anyway. Well, in my opinion. Do you remember when I built my CSS preparser from a XML parser? Just by rewriting it into a 100% PHP solution, it suddenly was twice faster to parse. (I know I only had two different xml tags to parse, but still... Complex nesting and all.)
Quote
Hence the reason I could implement <we:if "expression">, < tpl:something > will not break things since it'll be treated like a string, <tpl:something> will since tpl is a reserved namespace and it is unclosed, but it'll give a nice error message! And yeah, TOX-G can self-close tags :P.
As we said last time -- I like Tox-G, and I like the way Unknown solves problems, but I can't deal with it all by myself. If you guys went ahead and converted the templates for us, it would sure be nice. Right now, the best I can do is look through all of the non-admin templates, split them into as many sub-functions as required, and use PHP/HTML mode switching instead of echo's. Really... Best I can do, theoretically.

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
Re: Plugin hooks
« Reply #87, on April 1st, 2011, 05:08 PM »
I can't do a damn regardless until I get to see the code, so I guess we'll wait till you release something. Till then, I'm waiting patiently :).

texasman1979

  • Posts: 99
Re: Plugin hooks
« Reply #88, on April 1st, 2011, 05:09 PM »Last edited on April 7th, 2011, 04:54 AM by texasman1979
...

MultiformeIngegno

  • Posts: 1,337
Re: Plugin hooks
« Reply #89, on April 1st, 2011, 06:26 PM »
I think that for "yall" he means "you all"... :unsure: