Page 2 of 2

Posted: Tue Apr 08, 2008 4:31 pm
by yellowled
judebert wrote:I'm on board! I'm facing some frightening deadlines at work, but I'll tell Eri we need to stop watching Dr. Who during the evenings: I have to save the day!
Similar situation here, but so far, my deadlines are manageable. I may, however, not be available in the evening (my time; once again, I have no idea what that is your time) that much. We'll figure it out using the forum or email, I guess.
judebert wrote:Handling the CVS is no big deal.
Remember, we're working with core and shipped plugins first - that's SVN :)
judebert wrote:Don: if nobody else does, I'll outline how to Smartify a plugin later this evening.
Also, I guess we don't have to smartify everything. As far as the core plugins I outlined earlier in this thread are concerned, I guess we don't need to smartify any of them. Of course it would be nice to have them smartified ... :wink:

YL

Posted: Wed Apr 09, 2008 5:01 am
by judebert
How to Smartify Your Output

Let's cover basic use of Smarty for s9y developers. We'll be using a hypothetical plugin that produces an archive of webcomics for you.

Step 1: Decide what kind of data you need to create decent output. In our example, that's probably a list of comics, each of which has a title, an image, a number, a date, and a transcript.

Step 2: Place all that data in an array with descriptive keys. We'd probably be creating an array of arrays, something like this:

Code: Select all

$archive = array();
foreach ($comic as $allcomics) {
    $archive[] = array('img' => $comic['image], 'title' => $comic['title'], 'number' => $comic['index'], 'date' => $comic['published_on'], 'transcript' => $comic['script']);
}
Step 3: Assign the array to Smarty using a descriptive name.

Code: Select all

$serendipity['smarty']->assign('comic_archive', $archive);
Step 4: Create a default template to use this output. In Smarty, we'll want to iterate over each entry, printing it appropriately:

Code: Select all

{foreach from=$comic_archive item='comic'}
    <h3>{$comic.title}</h3>
    <p><span class="date">{$comic.date'}</span> #{$comic.number}</p>
    <img src="{$comic.img}">
{/foreach}
You don't have to use all the stuff you put in the array. But for a default template, it's a good idea, just so future modders know what's available.

Step 5: Find the template file. When you're ready to actually print your template, call:

Code: Select all

$tpl = serendipity_getTemplateFile('mytemplate.tpl');
This will either return the path to the template file as defined in the current template, or empty, or the plain name of the template. You can use file_exists() to see if a valid template was returned, and default to a known working template if it isn't.

Step 6: Call Smarty to produce the output.

Code: Select all

$html = serendipity_smarty_fetch('UNIQUE_NAME', 'mytemplate.tpl', false);
print $html;
If you pass 'true' instead of 'false', the output will be directly printed. Additionally, the output is assigned to {$UNIQUE_NAME} in Smarty, in case you want to get at it again later. Serendipity will call serendipity_getTemplatFile on 'mytemplate.tpl' again; if you passed a full file name (like a default from Step 5), it should work.

And that's all there is to it! If we find errors in this, I'll be editing the post to correct them.

Posted: Wed Apr 09, 2008 11:00 am
by d_cee
BTW, I still want to use BP as default for 1.4. I'm just waiting for Don to check in the carl-look-alike-colorset to BP to make the switch.
I realise I'm not very active just now but would somebody explain what 'carl-look-alike-colorset' we're talking about here.

Dave

Posted: Wed Apr 09, 2008 12:42 pm
by garvinhicking
Hi Dave!

I mean a colorset that makes BP look like the carl_contest template as much as possible, because I'd like to not break most of the current s9y look for a interrim release. Breaking the look of the layout is scheduled for 2.0 earliest ;)

Regards,
Garvin

Posted: Wed Apr 09, 2008 2:18 pm
by yellowled
Okay, in an act of bravery, I just now committed changes to the archives and authors plugin to SVN. Gee, that's a strange feeling :)

The syndication plugin is a bit tricky, but I'll try to address that later. It would probably be a good idea if someone with a little more PHP knowledge checked my code :)

Edit: syndication is done, too. However, there's a small quirk: If the plugin is active, put no feed is selected in the plugin configuration, does it still generate the content? If so, we'll have an empty <ul></ul> now. Maybe someone can come up with a smart solution for this, this is where my PHP ends :)

YL

Posted: Wed Apr 09, 2008 3:58 pm
by Don Chambers
d_cee wrote:
BTW, I still want to use BP as default for 1.4. I'm just waiting for Don to check in the carl-look-alike-colorset to BP to make the switch.
I realise I'm not very active just now but would somebody explain what 'carl-look-alike-colorset' we're talking about here.

Dave
Dave - quite some time ago, YL & I came up with a bp colorset that emulates the current Serendipity 3.0/carl_contest template. You were copied on the email containing the source. I need to do some slight changes, and will make sure you are either copied again, or will personally let you know when I check it into svn.

@ YL - sounds like you are "on a mission"!!! :lol:

Posted: Wed Apr 09, 2008 4:49 pm
by d_cee
Thanks Garvin / Don
Don Chambers wrote:Dave - quite some time ago, YL & I came up with a bp colorset that emulates the current Serendipity 3.0/carl_contest template. You were copied on the email containing the source. I need to do some slight changes, and will make sure you are either copied again, or will personally let you know when I check it into svn.
I don't seem to have that so I guess this was during the two weeks I lost my email accounts. - and all mails during that period! Thanks BT (a warning for anyone in the UK with BT as their ISP - don't believe their customer services when they say they won't suspend your email accounts when you change from BT Home to BT Business 'cos they will!)

I wouldn't mind taking a look so I'd be grateful if you'd send it again Don :-) - and if you've no time to finish it I could take a look next week, if you like, as things are a little more sorted in my life now fortunately (but I'm busy this week).

cheers
Dave

Posted: Wed Apr 09, 2008 10:39 pm
by yellowled
Don Chambers wrote:@ YL - sounds like you are "on a mission"!!! :lol:
Is that code for "We'll just let you do the whole thing by yourself while you're at it"? 'cause if that's the case, I won't come very far :wink:

Seriously: I will continue to revise plugins when I find the time, but it is definitely necessary that someone with more coding knowledge checks up on my code.

And, no, this is not going to become a "Let's finally teach YellowLed some PHP by not helping him" kind of project! :wink:

YL

Posted: Wed Apr 09, 2008 10:45 pm
by garvinhicking
Hi!

All the code you committed today looks solid to me. :) But it won't hurt if others want to check it, too :)

Regards,
Garvin

Posted: Thu Apr 10, 2008 12:29 am
by yellowled
garvinhicking wrote:All the code you committed today looks solid to me. :)
I was proud that I even remembered to commit each plugin seperately :)
garvinhicking wrote:But it won't hurt if others want to check it, too :)
Especially because I don't claim to be omniscient in terms of semantic markup :)

YL

Posted: Thu Apr 10, 2008 1:14 am
by yellowled
Okay, next up: serendipity_plugin_comments. That's right, folks, I'm getting started on the non-internal core plugins :)

This one only needed some small tweaks, and the changes probably won't even break any old templates. However, I think this should definitely get smartified. I have read Jude's how-to, but to be honest ... I don't understand a single word of it :lol:

I like the new default code, and I think designers can do a lot with it already, but I also think a smartified version would give us so much more possibilities. Jude? Anyone?

YL

Posted: Thu Apr 10, 2008 4:43 am
by judebert
Still buried, but digging my way out.

Oh, no! Another dump truck!

Today my company informed me that they've installed a charging space for my electric car! I've got to finish its maintenance so we can take pictures.

It may take a while to dig my way out of here...

Posted: Thu Apr 10, 2008 5:27 pm
by mattsches
Just found out what guys are about right now - and I think it's great, it's the right way to go. From the perspecitve of semantic HTML this has been overdue for a while. I will take a closer look at "my" plugins and see what I can do.

Keep it up
- Mattsches