News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Oi! Purple Peeps! I haz question.

Started by Antechinus, January 09, 2015, 03:51:25 PM

Previous topic - Next topic

Antechinus

Us well-behaved and responsible theme authors are supposed to load custom theme strings in the usual file. That's fine in most cases, but I'm writing up some reasonably comprehensive help sections just in case they are needed. Obviously it's pointless loading these all the time when they won't be used that often.

Question: is it permissible for themes to include their own copy of Help.english.php, with the custom strings appended to the end of the file?

If not, is it possible for a theme to automatically have its own help file loaded just by using the Help. prefix on the file name? (ie: Help.ZOMG.strine.php)

Deaks

TBH their are no guidelines saying that you cant edit help.english.php if you are creating a theme to be submitted to theme site.
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Antechinus

Yeah that would be my preferred option since it's clean and simple, but if there's a more kosher way of doing it I'm up for that too.

Deaks

if you were doing it as a custom file, it would then fall to how you called it, technically you can use include or require but its frowned upon.  Without also adding a mod for the theme I cant think of a better way to do it :/
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Gary

I've used require() in my themes, but for template files. And personally I don't really mind it for language files for a ThemeHelpStrings.language.php or some other related filename either, so long as you're still able to detect which language is being used.

I'd rather avoid having to edit Help.language.php but if all else fails, then that's okay by me.
Gary M. Gadsdon
Do NOT PM me unless I say so
War of the Simpsons
Bongo Comics Fan Forum
Youtube Let's Plays

^ YT is changing monetisation policy, help reach 1000 sub threshold.

Antechinus

Ok, so how would you detect which language was being used?

margarett

I'm not sure because that is something I never did and I'm on the phone, can't check the code but I think you can use loadLanguage('YourLangFile'); but the file YourLangFile.english.php should probably have to be in $languagedir, which is Themes/default/languages...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Antechinus

Oh poo. :P This is getting complicated. Don't need an immediate solution anyway. This is just thinking ahead.

If it's going to be a drama I might just paste the help/tuts stuff to the theme thread, and link that from admin.

Deaks

Not really just use languagedir instead of scripturl in the require.
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Antechinus

Yeah but how does a theme install get a file into that directory? That's the tricky bit. You'd need a mod for that, or have to rely on the admin loading it themselves (which is scary :D ).

Deaks

just stick it in your themes language folder lol
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Antechinus

Yeah I know that, and you know that, but teh n00bz don't know that and I'll have to tell them. Probably frequently. Then they'll put it in the wrong folder anyway. :P

ETA: I'm assuming Margarett is right and that will be the default languages directory.

onepiece

Create your custom language file, name it HelpCustom.english.php and put it in the /Themes/your_custom_theme/languages directory. (it doesn't need to be in the default theme directory) Then just make sure to have the following line of code right at the beginning of the function in your template file that you need those language strings for:

loadLanguage('HelpCustom');

The function will (first) look at the current theme (as well) and since that language file won't be called by any other theme, there are no problems with having that file only in your custom theme directory.

Antechinus

Oh cool. Well that's a piece of cake then. Thanks for the clarification. I'll do that then. :)

Can I call it FlyingWombatz.english.php instead though? I kinda like the sound of that. :D

Antechinus

Ok so that works, which brings up something else. Is it possible to load a CSS file by template, without going through Sources?

margarett

Errrr, the normal loading method doesn't work?

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Antechinus

There aint no head in Help.template.php. ;)

What I was wondering was if it would be possible to split the help CSS out of index.css, since I've just managed to split the help theme strings out of ThemeStrings.english.php. This is just in the interest of reducing initial download and cache hits to phones, etc. If it's not doable outside Sources that's fine. I was just wondering. :)

onepiece

What you can do is to set it so that the related HTML code is added only on that particular action. In your index.template.php file:

Code (Find) Select
// RTL languages require an additional stylesheet.

Code (Replace) Select
if (!empty($context['current_action']) && $context['current_action'] == 'help')
echo '
<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/help.css" />';

// RTL languages require an additional stylesheet.

Antechinus

Ah. Good one. Will give that a whirl. It's just that index.css is getting a bit bigger than I'd prefer, what with all the responsive and eye candy stuff, so trimming it a bit might be a good idea.

Advertisement: