MyBB Community Forums

Full Version: Friendlier templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

I'm really new to MyBB and I was quite satisfied with the features and how it's close to vB 3.8. Until I came across theme development.

The arrow in the knee here is storing themes in a database and a lack of support to get it out of it, i.e. creating themes through administration. There are just too many cons using browser and textareas over IDEs.

I tried to export a template, it exports only differences between child theme and parent theme, however. Single XML file is another obstacle.

I don't think there's a need for a big change. Actually, an option to export all templates would do the job. One file each is essential here.

That's what I've tried myself before creating a new theme.

<?php

$username = "root";
$password = "";
$hostname = "localhost";

$dbhandle = mysql_connect($hostname, $username, $password)
	or die("Unable to connect to MySQL");

$selected = mysql_select_db("mybb",$dbhandle)
	or die("Could not select database");

$result = mysql_query("SELECT * FROM `templates` WHERE `sid` = '-2'");

while ($row = mysql_fetch_array($result)) {
	$file = "templates/" . $row['title'];
	$filehandle = fopen($file, 'w')
		or die('Cannot open file: ' . $file);
	fwrite($filehandle, $row['template']);
	fclose($filehandle);
}

mysql_close($dbhandle);

This works well for themes inherited from MyBB Master Style. It doesn't take prefixes into account, so it doesn't make subfolders for template groups. Doesn't work for themes with another parent theme, ofc. So far, I haven't need it.

Such an export could help theme developers and make their work with MyBB way friendlier.

Thoughts?
It may make editing exported themes easier but it would make it harder to import the theme.
I'm not saying cut off the single xml file export, that works perfectly... Once the theme is done. But for development purposes, the built-in editor can't compare to IDEs or text editors. Yup, you would have to keep track of changed templates (e.g. saving them to another dir) and copy those through ACP when done.

Apart from that, support for importing multiple template files is not hard to code. The only difference would be checking changes for each template, which is most likely already done in MyBB. And in our midst, comparing two strings is not a big deal.

What would be ideal is switching between (or syncing) database and file system, because most of the theme developers still checks the changes quite frequently in a browser. And ctrl + s; alt +tab; f5 is faster than copying / importing the template through administration (aka ctrl + a; ctrl + c; alt + tab; switch to backend tab; searching the template; ctlr + v; save; switch to frontend tab Smile)

I didn't check how templates are loaded yet. It might not be hard to code this either. Or might be. That's why I haven't opened the topic. Yet? Smile
Personally, I'd rather see an implementation of WebDAV support to allow editing the templates straight from your IDE (most decent ones support it after all) rather than having the hassle of downloading anything at all.
(2012-09-10, 05:41 PM)euantor Wrote: [ -> ]Personally, I'd rather see an implementation of WebDAV support to allow editing the templates straight from your IDE (most decent ones support it after all) rather than having the hassle of downloading anything at all.

The question now would be, how many hosts actually supports WebDAV, or php WebDAV for that matter.
That I'm not sure of. I know that mine does for certain Wink
WebDAV support would be the best solution to this.

I am sure most/good host support it. Out of all the host I have used they all supported WebDAV.
(2012-09-10, 09:07 PM)euantor Wrote: [ -> ]That I'm not sure of. I know that mine does for certain Wink

You still with webfaction? I'm to lazy to look if they have it Toungue. But, how developer friendly they are I would imagine so Big Grin.
(2012-09-11, 04:31 AM)Alex Smith Wrote: [ -> ]
(2012-09-10, 09:07 PM)euantor Wrote: [ -> ]That I'm not sure of. I know that mine does for certain Wink

You still with webfaction? I'm to lazy to look if they have it Toungue. But, how developer friendly they are I would imagine so Big Grin.

Sure am. Haven't considered another host since your recommendation Smile
WebDAV, WebDAV...

[Image: y7Hm9.jpg]

Smile

When I do, I do it locally. Well, I don't need WebDAV to manage local files Smile

It took me 10 minutes to code an app, which pulls changed templates on a request. A single line in a global.php so the request comes with a reload and it works like a charm. It's not the cleanest way, but hey - I'm not going to use it in production.

Even though the official implementation should be a bit more thought-out, it would still be easier to implement than WebDAV.

When thinking about it now, plugin would do the work too.
Pages: 1 2