News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Why Not Use PHP's Alternate Syntax For Templates?

Started by user2037, September 20, 2007, 08:05:19 AM

Previous topic - Next topic

motumbo

Quote from: Dragooon on September 27, 2007, 09:08:41 AM
Because WordPress is not SMF. You really wont be able to do this due to the mind blowing foreach loops.

Wordpress is #1 in blogging scripts.  Obviously, they are doing something right.

Kindred

and wordpress is much simpler than SMF.

Motumbo...  You complain about arrogance on the part of SMF. I disagree completely.  Rather, I see arrogance on the part of users like you who think that Your way is the only right way and your concepts MUST be the most important thing to be done in "the next release, immediately".

SMF is quite successful. We are free. We will always be free.
We listen to the users, and while we may not agree with some of them, we respond and give reasons why we may not do something (or why something is better considered as a mod).

and FYI: the two people you responded to (Rudolf and Dragoon) are not SMF team members...  So any arrogance or condescension you see from them is the arrogance and condescension from other USERS of SMF.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Rudolf

motumbo, I won't quote your post or parts of it because that would be like we are fighting or something.  I'll just address some points in your answer.

You say that you look at Wordpress and you see right away how stuff works. But you don't tell how many time you spent looking at the Wordpress code. If what you're suggesting that as soon as you opened a Wordpress source file or theme the first time you knew exactly what was going on, then I just don't buy it. You spent time familiarizing with Wordpress, therefore now you know how things work. If you say that it takes more time to get used to SMF then to Wordpress, then that's something I can accept. Probably it's so. However having a bad code is not the only possible reason. SMF's system is probably more complicated then Wordpress, thus it's harder to get used to. On the other side, I can do whatever I want with an SMF installation, I can make it whatever I wish to be: blog, social networking site, shopping cart, issue trackig software, or the admin interface to your home appliances. And all this would be a walk in the park to do it, using the core "framework". I don't know about Wordpress.
Fact is that you actually need to know programming to do all these things.

You are vagues. There are two concepts. One is when people want to make their forum look like their site(or blog), the second is when they want to integrate the forum into their site. For this you need HTML knowledge, very basic PHP knowledge (not programming related!, the user just needs to know what the echo '' commands) and finally knowledge of the stuff(variables) you can use in the templates SMF (this one is a matter of documentation, which is a different subject). In this case I hardly believe that Wordpress is better then SMF, maybe it's code is easier to read, but in the end it's all a matter of getting used to.
With integration, they want to have topics, post, statistics to appear on their site, outside of the forum. In the case of the integration, you need all of the above and some extra programming knowledge if you want to do exotic stuff.

I am not talking about forcing people to learn how to do error handling, object oriented programming and other stuff. Just some basic rules that everyone with a little common sense should be able to grasp.
What I'm trying to say is that if you face the people with the choice of something valuable but which requires learning or something simple but limiting, people will use the simple stuff. Because they are lazy.
I converted a bunch of people from IE to Firefox, and they were against using the tabs. They were not used to it. They said: I don't understand how it works. Now I ask you, is it so hard to grasp tabs in Firefox? People were using the task bar for years, but when presented with something similar inside a program they "didn't understand it". All those people who finally managed to put aside their laziness and prejudices thanked me afterwards for showing them the light.

This is what I mean, when I say that one has to decide to limit the features and the power of the system just to accommodate people's laziness.

Break up a complex algorithm in small function s and you'll have a performance drain. There is a balance where breaking up the stuff is useful. SMF 1.1 was probably below the limit having too large blocks, imo SMF 2 went too far and broke up in too many pieces. You'll spend a lot of time in SMF 2 hunting for functions and files. Maybe you'll like it more then the current system, I don't. Of course, once you get to know them all of this won't matter.

You say many hours of intense code study? Well, it took me only a couple of hours (spanning 3-4 days) to understand how the templating system works. Given that I count myself as an advanced user/average programmer,  I bet that an average user could learn it and understand it in less then a week. If they would take the trouble to do it. I haven't read the documentation on the theme system as there was none at the time. Present folks have the advantage over me of having a function database, an online manual.

Tables are not ancient the way they are used is. That's one point I don't like SMF either. But things are changing. Still, I seriously doubt that you had to go into a Source file to track the cause of a <tr>.

About the company, I can understand you. I work at a similar company and I am pushing for the same things. We have the same concept of the things, just that I don't take it to the extremes. There is a limit where the drawbacks outweigh the benefits.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

phpMaster

#23
hi

I dont understand why some people stick to bad coding habbits.
Using short tags, I mean.
They maybe never have open and read this file:
-> php.ini.recommended <-



Anyone keep using <? and <?= will be asking for trouble. In near future.
As soon as possible and well before when PHP 6 arrives,
I hope most web servers will have learned to use snd switched to:
short_open_tag Off


I have always taken hxxp:php.net [nonactive] recommendations seriously.
I dont pretend to know better than they do.
So for several years!!! now, my server settings have been.

register_globals Off
short_open_tag Off
magic_quotes_gpc Off



If we dont stop those bad habbits by ourselves now,
we will have to learn it the hard way: Hours and days to rewrite bad coding :(


Regards  :)
... i do php code ...

Dannii

#24
I don't like the idea of an alternate syntax, but I do like the idea of a sort of "theme compiler" where you could use many more functions (macros would be a better description, but I don't know if PHP has them), which are then squashed down into one. It would be the best of both worlds - efficiency and simplicity, while not restraining theme authors in any way.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

motumbo

I recently had the opportunity to look at some other popular open source scripts like CMSes and you know what, they ALL use PHP's alternate syntax for templating.  All the ones I looked at, anyway.

Wordpress, Drupal, Mambo, Joomla--all use PHP's alternate syntax and all the templates are easy to modify.  And none of them use tables for layout!

The reason I decided to look at some other programs is because I read some criticism of SMF's code on another forum so I wanted to see just how other popular open source projects did it.  (The person said SMF's code was was ugly, in case you are wondering.  Also if you are wondering, I do agree with that sentiment.)

SMF is going to go the way of the dodo if the developers don't get their act together and code it to modern expectations.  (If you want, in the future I will save links to all critical comments about SMF's code so you people can see for yourselves.)

I will be willing to chip in for a book on CSS for any of the developers who never learned how to create websites without using tables for layout. 

I absolutely cannot fathom how anyone in this day in age can insist on using tables for layout (except for tabular data, most of which SMF is not).

In terms of open source script code, SMF is like an old man with plaid pants and greased back white hair trying to hang out teenagers, never realizing he's an object of ridicule.

Dragooon

#26
I am not going to argue here or make a long story but here is MY experience.

Before on day 1 when I started using SMF, I installed it successfully and it was fairly easy. Then I had to change some stuff on the templates, get new themes and so on(The customization). I got everything but still I wanted some changes. So I looked into templates and wasn't able to understand it. At that point of time I didn't knew PHP/HTML. Later I grabbed a few Books and studied PHP and HTML With MySQL. Once done, I hanged out with Sources files and Templates for about 3-4 hours a day for about 5-6 days and I was able to understand what all is happening and how is it happening. Thanks to the logical coding and comments that were there.

Once I got hang of it I tried to made it what I wanted, And it almost worked like it. Later on I was able to install big mods on themes which were different than defaults and so on I kept improving and it didn't take much time.

Now I have quite a good idea how SMF works and its templating system works, And I am finding it fairly easy. I am No great PHP coder or a HTML guru. I am just a average PHP/MySQL/HTML coder but still am able to make out how it works and modify it quite the way I want it.

As said by Kindred I am no SMF Team member, I am just a user like anyone else.

I am with Rudolf with the fact that you can understand with a average knowledge of PHP and HTML. Its not hard.

I haven't Looked at other CMS or any other PHP software neither I am taking Side of SMF. But this is my point of view or say my experience.

motumbo

Quote from: Dragooon on October 18, 2007, 12:50:20 AM
I am not going to argue here or make a long story but here is MY experience.


I see no problem with civilized debate.  Do you?

Quote from: Dragooon on October 18, 2007, 12:50:20 AM
Before on day 1 when I started using SMF, I installed it successfully and it was fairly easy.

The installation of SMF is indeed quite easy.  The customization is not.

Try to erase your experience and knowledge of SMF.  Take a look at the templates.  Then take a look at the templates of Wordpress, Joomla, Mambo, Drupal, etc.  Which are easier to understand and modify?

There is no arguing that SMF templates are many orders of magnitude more difficult to modify.  Nobody around here can argue that. 

The default theme of SMF is not pretty.  In fact, the default themes of most open source projects tends to be bland at best to outright ugly (like Wordpress).  Given that fact and given the fact that most webmasters want to make their forums look like their sites, it is a no-brainer, to me anyway, that the SMF template should be designed to be as easy as possible to understand and modify.  That means no ugly javascript embedded in the template.  And that means no tabled design.  And that also could mean adopting the same kind of templating structure as the leading open source scripts.

Wordpress, Joomla, Mambo, and Drupal do their themes one way and SMF  insists on doing theirs another.  Who's right, who's wrong?


Dannii

QuoteWho's right, who's wrong?
Everyone is wrong, but some are more wrong that others. ;)
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Kindred

however, motumbo...   none of those other have the flexibility in theming and templates that SMF does.

SMF's templating system may seem a bit complicated at first, but it is also one of the most powerful in terms of what you can do with it.
Seriously, I would not be able to do half of this stuff with mambo/joomla... and mambo/joomla essentially only have a single index template.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

karlbenson

Copied from my PHP.ini (the same should be found in yours)

Quote from: php.ini
; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On

The question should probably be put to other sites which use short tags to why they are avoiding the advice of the product makers. Indeed, its 'bad coding' on their part.

motumbo

#31
Quote from: Kindred on October 18, 2007, 08:38:32 AM
however, motumbo...   none of those other have the flexibility in theming and templates that SMF does.

You are kidding, right?

Quote from: Kindred on October 18, 2007, 08:38:32 AM
SMF's templating system may seem a bit complicated at first,

Who could possibly argue that td, tr, rowspan, colspan are not complicated?

Quote from: Kindred on October 18, 2007, 08:38:32 AM
but it is also one of the most powerful in terms of what you can do with it.
Seriously, I would not be able to do half of this stuff with mambo/joomla... and mambo/joomla essentially only have a single index template.

They have a single main template.

SMF has a main template, too, which consists of the above and below functions in index.template.php.  The board index, message index, display, and other stuff change.  But the template above and template below stay largely the same with some data changes, but the layout is the same.

So, what do we have?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php $charset ?> " />
<meta name="description" content=" <?php $description ?> " />
<meta name="keywords" content=" <?php $keywords ?>" />
<!-- Other stuff that goes in the head -->
</head>
<body>
<?php $userinfo ?>
<?php $linktree ?>
<?php $content /* Board index, message index, message, post screen, whatever is pre-generated from the Sources files /* ?>
<?php $recent_posts ?>
<?php $who_online ?>
<?php $footer ?>


That's a crude example and is not indicative of a finished template.  However, that is 100 times easier to work with than what SMF has now.

Customizing something like that would be a breeze.

How easy would it be to take something out like whos online if you wanted it out?  How easy would it be to reorder those things?  It would be extremely easy.

karlbenson

All your doing there is removing sections out of templates.
In removing php out of the templates, your moving html into the source files. Trading one for another.

As has been said
Whilst it cuts down on php in templates, it reduces flexibility because now EVERY theme has the same $userinfo, $footer
This reducing smf to any old forum software.

As a mod author, I'm trying to move as much as php as possible into source files , but for smf to be as powerful, customizable, flexible there the templates need to be php based rather than html with bits of php.

Dannii

Mmmm. I believe the future will be in compiled/pre-parsed templates. Give the authors freedom to do whatever they like, while keeping all the performance benefits of straight PHP.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

motumbo

Quote from: karlbenson on October 18, 2007, 05:33:21 PM
All your doing there is removing sections out of templates.

That's the idea.  You make the final template--which is what most theme customizations will be applied to as simple as possible. 

You get rid of the ugly javascript.  You get rid of most of the if-then logic.   All the ugliness and mess is removed leaving a simple template for people to modify.  The logic to generate the content and the templates to produce it are elsewhere.

Quote from: karlbenson on October 18, 2007, 05:33:21 PM
In removing php out of the templates, your moving html into the source files. Trading one for another.

Not really.  The HTML to generate the $content, which consists of the board index, message index, post screen, etc., would come from the BoardIndex or Display or other templates then be assigned to $content before the final template is called. 

Quote from: karlbenson on October 18, 2007, 05:33:21 PM
In removing php out of the templates, your moving html into the source files. Trading one for another.

As has been said
Whilst it cuts down on php in templates, it reduces flexibility because now EVERY theme has the same $userinfo, $footer
This reducing smf to any old forum software.

SMF has pretty much the same footer on EVERY page.  So what's the difference?  The values of $userinfo, $footer, or whatever else are generated elsewhere and conditional on whatever page is called.

And actually, it wouldn't be reducing SMF, it would be a huge step up.

Quote from: karlbenson on October 18, 2007, 05:33:21 PM
In removing php out of the templates, your moving html into the source files. Trading one for another.

As a mod author, I'm trying to move as much as php as possible into source files , but for smf to be as powerful, customizable, flexible there the templates need to be php based rather than html with bits of php.

That's where you are absolutely wrong.  Anyone who has customized themes for Wordpress and SMF will tell you that Wordpress is much easier to work with than SMF.

That means:  less work for forum owners, less requests for help in the SMF support forum, more mods, more themes, etc.

I spent probably 2 hours customizing my Wordpress blog theme.  I spent about 20 hours doing the same with SMF.

Even a newbie to HTML or PHP can understand a Wordpress theme.  The same CANNOT be said for the SMF system.

Perhaps reasoning with people who think layouts should be done using tables is a waste of time...

When 2.0 comes out I'll spend a weekend or two recoding it the way it should be done.  Then we'll see which is more popular among the masses. 

Kindred

Sorry...   having designed Wordpress, mambo/joomla and smf themes, I find the SMF themes to be the most powerful and configurable.

Mambo/joomla themes are so basic that you really can't do much to them with ADDING a bunch of PHP and/or javascript into them (which is what I ended up doing...  adding about 200 lines of php and javascript to get the theme to do the stuff I wanted)

Wordpress might be easy to modify within the basic layout... but changing that layout is a bear.

The if-then logic in the SMF templates is a STRENGTH of flexibility...  you can display different things based on different conditions.

And the footer and header *ARE* separated out from the rest... that's what is in the top and bottom functions of index.template.php you'd ask us to dump those into YET ANOTHER file which would have to be included?  You're talking about adding more overhead to each page display.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SlammedDime

How could you reasonably expect a feature rich application (or script in this case) to not use things such as AJAX, for example, or more generally, javascript?  AJAX requires javascript by nature and design, and with no javascript in the template, it would not exist or be usable here on SMF.  Arguing that it prevents SMF being used by clients that don't have javascript enabled on their browser. 

What you're arguing here is similar to if you were to go to a Windows forum, inwhich Windows developers answered support questions and gave support for their product and started telling the developers that the way they present the GUI layer of Windows should change to reflect something similar to how gnome or KDE work because its 'better'.  Telling SMF they shouldn't use 'all that javascript' in their templates would be similar to telling Windows that they shouldn't use stuff that relies on the .Net framework in their GUI because gnome or KDE don't.

Granted, that above argument is not solid, and I realize that, however you get my point.  IMO, you came across the wrong way in presenting this, or rather, arguing this to the Developers / coders here at SMF.  If you wanted to show how something was better, comparing SMF to a CMS ( A CMS, which stands for Content Management System, not Bulletin Board Software) was the wrong way to go about it.  If you're a programmer and felt that the SMF was lacking in any way, perhaps taking the initiative to create a POC work and present it to the team and say 'Hey look, I've made these changes and in testing, appears to run faster and is easier to read and understand', then maybe your argument may hold some water, but at this point, you have pretty much zero credibility.

I would like to comment on something else you've hit the head on a couple times.  Being new to coding/designing and understanding SMF.  If you install any web software and modify it, you've now become a web designer, however small of one that may make you.  Inherently, you now need to know and understand the languages in which you are working in, in this case, HTML, XML, PHP, MySQL, and Javascript.  Find me any modern php BBS or CMS script which does not utilize all, if not most if those?  Good luck finding one.  This of course requires one to understand how these languages work and interact with each other.  If someone fails to do their homework, that is their own fault and if they screw things up, it is because of their own ignorance.  You've made two comments earlier that really struck me as arrogant on your part:
QuoteWho could possibly argue that td, tr, rowspan, colspan are not complicated?
If any one who is a web designer thinks these are complicated, then perhaps they should into a different hobby.  If one is just 'starting' in designing, they have an obligation then to find out what they are and how they work.  Similarly, if one has never programmed in PHP, but attacks a php program, they have an obligation to find out how parts they are going to modify work, regardless of how they are coded.

And secondly:
Quote'collapse_href' => isset($row_board['canCollapse']) ? $scripturl . '?action=collapse;c=' . $row_board['ID_CAT'] . ';sa=' . ($row_board['isCollapsed'] > 0 ? 'expand' : 'collapse;') . '#' . $row_board['ID_CAT'] : '',
If one knows some basic HTML, they would know that href is used in forming urls, and since one can hopefully read, they would also see the $scripturl variable (and any previous working with that would tell one that its the url at which the board resides), and one could also see the words collapse, expand, and ID_CAT in that line.  One could reasonably expect that line of code to create a collapsible link for a category on the board index page. 

As you should know from your coding experience, comments aren't there to explain what a line of code does, they are there to explain what LINES of code do that aren't obvious.  Assuming that someone looked at the code you took that fragment from, they would see other assignments to an array, probably relating to an array of categories, and could surmise that that is what is being created.  A line by line comment of code is highly unorthodox in coding.

As a software engineer myself, I typically have no problem stepping into new languages and understand what they are doing without ever looking at documentation.  The semantics of (if (condition) do) in Lisp is quite obvious as if (condition) { do } in C.  The SMF code is not there for beginners to pour over and expect to create a one off application.  People who mess around in the SMF code (such as mod devs that create advanced mods (ad management, for example), have not just an understanding of the SMF code, but of PHP, HTML, Javascript, AJAX, and XML, and thus it is unreasonable on your part to expect the SMF team, or ANY development team to create their code so that a child could mess with it and do wonderful things with it.

These are my own comments and have no reflection upon SMF or its developers and team
SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

Rudolf

Quote from: SlammedDime on October 19, 2007, 09:15:44 PM
How could you reasonably expect a feature rich application (or script in this case) to not use things such as AJAX, for example, or more generally, javascript?  AJAX requires javascript by nature and design, and with no javascript in the template, it would not exist or be usable here on SMF.  Arguing that it prevents SMF being used by clients that don't have javascript enabled on their browser.

I don't remember hearing motumbo saying that SMF shouldn't use Javascript. Only that having Javascript in the template is bad, and I happen to agree.
Javascript code can and should be included from separate files in the header.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

SlammedDime

SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

karlbenson

It is impossible to put 100% of the javascript in js files.

Especially where AJAX is concerned, this is because all the language strings and url/uri/folders need to be defined in the page.
That is the only real way to pass php variables/language strings to javascript.

Advertisement: