News:

Wondering if this will always be free?  See why free is better.

Main Menu

a few ideas to improve smf codding.

Started by Oskar Calvo, July 22, 2010, 03:48:48 AM

Previous topic - Next topic

Oskar Calvo

Hello, first of all I want to say that I want to help, I don't want to break nothing or similar.

Now, the idea.
This is a smf standar code:

<?php
// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<b>'
$txt[616], '</b><br />';
?>


this is a drupal standar code:

<?php if ($context['in_maintenance'] && $context['user']['is_admin']): ?>
  <b><?php print $txt[616]; ?> </b><br />
<?php endif; ?>


Although in the example they seems similar, if we take a big html code we will see better.

It's only an idea, but it can help to understand the code faster.

Oskar

Antechinus

Yeah, inline php. I hate it. Really. I'd much rather do it the way we already do it. The second one is horrible from a formatting point of view IMO.

Oskar Calvo

Hello Antechinus.

The example is only for the themes files, not for all the files.

For the full files in drupal there are other way of works, but in the themes I think is the best way, IMO.

Oskar

Antechinus

I disagree but it's a matter of personal preference. The thing is that themes contain so much dynamic content that if you use inline php you end up with a dog's breakfast of php tags all over the place. Much cleaner and easier to just echo the lot.

It's different if you're doing a page that is mainly static with only a few little bits of dynamic content. In that situation inline php makes more sense.

Again, this is personal preference but you wont find many (if any) of the SMF team in favour of changing to inline php.

ETA: Of course if you want to rewrite templates for your own use there is nothing stopping you doing this.

Oskar Calvo

Quote from: Antechinus on July 22, 2010, 06:38:39 AM
ETA: Of course if you want to rewrite templates for your own use there is nothing stopping you doing this.

Yes, I'm

Oskar.

Advertisement: