Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Slogan plugin
#1
Simple plugin written during one evening.

As I was making sites for my client I restricted their access to 'Themes' tab by wonderful Multi user plugin. This ensured that themes template files won't be corrupted by ordinary users. I used 'components' in 'Themes' tab to place there small phrases and slogans from page titles or sidebars (and they've been translated by i18n plugin, thanks to Mvlcek). As this slogans contained some user info (such as emails, telephone numbers etc) I decided to write a slogan-plugin, that would be editable by users in 'Pages' tab.

Usage
Usage doesn't differs from 'component' usage.
Code:
(%slogan-name-goes-here%)
- without any spaces between (% and slogan name, for usage in page content
Code:
<?php get_slogan('slogan-name');?>
- for usage in theme template files

The result is the same as with components - the phrase for current language will be returned or for default language (if the first one is empty).

Requirements
  • i18n plugin by Mvlcek
  • GS 3.1, BUT it may work on GS 3.0, I didn't test it
i18n wasn't made, because there is almost nothing to translate except 2 buttons and header Wink, but if you really need it, post a reply and I'll do my best to add i18n support.

[Image: slogan.png]
Reply
#2
Zorato Wrote:Simple plugin written during one evening.

As I was making sites for my client I restricted their access to 'Themes' tab by wonderful Multi user plugin. This ensured that themes template files won't be corrupted by ordinary users. I used 'components' in 'Themes' tab to place there small phrases and slogans from page titles or sidebars (and they've been translated by i18n plugin, thanks to Mvlcek). As this slogans contained some user info (such as emails, telephone numbers etc) I decided to write a slogan-plugin, that would be editable by users in 'Pages' tab.

Usage
Usage doesn't differs from 'component' usage.
Code:
(%slogan-name-goes-here%)
- without any spaces between (% and slogan name, for usage in page content

Nice that I'm not the only one writing plugins that are multi-language capable :-)

Just one comment:
Your syntax differs from the de-facto standard for GS and might clash with other plugins.
E.g. if the user has I18N Gallery installed and uses a slogan "gallery" then - depending on which plugin loads first - either I18N Gallery won't work on that page or would remove the placeholder and Slogan won't work.

It would be better to use a syntax of (% slogan slogan-name-goes-here %) like the other plugins using (% ... %).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
any chance to optionally use ckeditor for the fields ?
Reply
#4
(2013-04-01, 12:58:03)tazmandev Wrote: any chance to optionally use ckeditor for the fields ?

I dont have enough time to implement that. Feel free to modify any scripts if you need to. I suppose this wont be very hard, use standart 'pages' tab as an example. Ask any questions, I'll do my best to answer them.
Reply
#5
I have adapted your plugin to accept translation, and created english and romanian translation files.

( I use your plugin as an more elegant alternative to components, and Slogans did not seem to be a suitable module "name" for my client. )

This is very easily done with a translation file. I named my translations "Elements" trying to be self-explanatory.

I would like to post the modified version, but I think that it would be best for you to integrate the changes in a new release.

There is allso a tiny modification in slogan.js, at line 4,
I did not knew how to integrate i18n translation for a text in the js file

$('.new-slogans-box').append('Name: <input name="new_slogans[]" type="text" placeholder="Enter name of a new element"><br>');

notice the 'element' instead of slogan.
... placeholder="Enter name of a new element"

Modify that as you think suitable.

Here it is the modified version

.zip   slogans v1.2.zip (Size: 5.55 KB / Downloads: 9)

or on speedyshare:
http://speedy.sh/P6Rcv/slogans-v1.2.zip

Excelent job, and keep on the good work.
Reply
#6
Thank you for your contribution, it is really important for me. I've applied your changes in 1.2 release and added some new minor features. I've also added a few translations (I decided to put js code right into main .php file) so you can easily translate all messages to any language.
Reply
#7
This is great.
This plugin will become one of my "Default plugins" for Get Simple.
Reply
#8
Really good plugin. Exactly what I need. User defined components but keeping the user out of the Theme tab.
Reply
#9
(2014-11-18, 09:29:33)denis Wrote: Hello, I am using the plugin simple-contact.
Changed manually: $sc_to = 'name@mail.com';

Can I use the plugin slogan, that would change this line -
$sc_to = 'name@mail.com' ??

For example:

slogan-name-goes-here = name@mail.com

$sc_to = <?php get_slogan('slogan-name-goes-here');?>

or

$sc_to = '(%slogan-name-goes-here%)';

will it work?

As I can see $sc_to is a PHP variable inside PHP code. Try using return_slogan function:
PHP Code:
$sc_to return_slogan('slogan-name'); 
Reply
#10
I love this Slogans plugin, but I'd love to be able to use it without i18n because for simple sites I prefer to use the default GS Pages and menu systems.

Any thoughts on how to hack a non i18n version?
Reply
#11
(2015-03-24, 20:51:33)davetest Wrote: I love this Slogans plugin, but I'd love to be able to use it without i18n because for simple sites I prefer to use the default GS Pages and menu systems.

Any thoughts on how to hack a non i18n version?

This plugin was designed to be used with i18n. I can advice you to install i18n and to try using it with 1 language. Or you may decouple i18n on your own - I'm sorry, but I don't have time for that.
Reply
#12
(2015-03-25, 01:29:53)Zorato Wrote:
(2015-03-24, 20:51:33)davetest Wrote: I love this Slogans plugin, but I'd love to be able to use it without i18n because for simple sites I prefer to use the default GS Pages and menu systems.

Any thoughts on how to hack a non i18n version?

This plugin was designed to be used with i18n. I can advice you to install i18n and to try using it with 1 language. Or you may decouple i18n on your own - I'm sorry, but I don't have time for that.

Thanks Zorato, I guessed as much, but thought it worth asking. I run it fine on sites where I'm using i18n anyway for hierarchical menus etc, but I'm now working on a very simple site and would rather not instal i18n Base as it makes the the pages tab seem more cluttered and confusing to the user. I also believe in the Get-Simple approach where possible :-)

I certainly will give it a go myself, but php is not my strongest subject, so if you ever do get time to look at it yourself, there must be others like me who could use it.
Reply
#13
Small plugin that allows using Slogans without I18N:
Code:
<?php
// register plugin
$thisfile = basename(__FILE__, ".php");
register_plugin(
    $thisfile,
    'No-I18N patch for Slogans',
    '0.1', 'Carlos', '#', 'Allows using Slogans plugin without I18N base installed'
);

function return_i18n_available_languages() { return array('en'); }
function return_i18n_languages() { return array('en'); }
function return_i18n_default_language() { return 'en'; }

//end of file
Save as no_i18n_patch_slogans.php (for example), upload to your plugins folder and activate it.

Important note: this plugin/patch is NOT compatible with the I18N Search plugin.
Reply
#14
(2015-03-25, 03:42:28)Carlos Wrote: Small plugin that allows using Slogans without I18N:
Code:
<?php
// register plugin
$thisfile = basename(__FILE__, ".php");
register_plugin(
    $thisfile,
    'No-I18N patch for Slogans',
    '0.1', 'Carlos', '#', 'Allows using Slogans plugin without I18N base installed'
);

function return_i18n_available_languages() { return array('en'); }
function return_i18n_languages() { return array('en'); }
function return_i18n_default_language() { return 'en'; }

//end of file
Save as no_i18n_patch_slogans.php (for example), upload to your plugins folder and activate it.

Sir Carlos - thou art a hero - result!

Works a treat! thank you. - but make sure to remove or deactivate i18n Base first or you may get a conflict like I did - but all ok now.
Reply
#15
Why does it use i18n plugin at all ? Front end language detection?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#16
It's multilanguage capable. You can define language-specific texts.
Reply
#17
I mean why not use core or implement its own for such basic functionality...
What is missing core to do this ?
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#18
I would like to use this plugin to put announcements into my template in a way where the html div etc that I surrounds the slogan does not display if the slogan is empty. But I'll still want to keep the particular slogan existing in the backend ready for an announcement and be able to just save it as an empty field when there isn't an announcement. So I'm not looking to detect if a slogan exists (though it would be nice to know how to do that too) I'm looking to find what php code would only display the whole div (etc) containing the slogan if it has content (or maybe contains more than x characters?).
Any ideas please?
Reply
#19
(2015-04-14, 20:21:49)davetest Wrote: I would like to use this plugin to put announcements into my template in a way where the html div etc that I surrounds the slogan does not display if the slogan is empty. But I'll still want to keep the particular slogan existing in the backend ready for an announcement and be able to just save it as an empty field when there isn't an announcement. So I'm not looking to detect if a slogan exists (though it would be nice to know how to do that too) I'm looking to find what php code would only display the whole div (etc) containing the slogan if it has content (or maybe contains more than x characters?).
Any ideas please?

What I'm trying to do is use in my template:
PHP Code:
<div><?php get_slogan('Announcement');?></div> 
But I need a php solution so that if the slogan has no content, the div tags will also not display. That way I don't get to apply any of the css attached to the div.
Can any php expert point me in the right direction?
Reply
#20
I am no way a php expert but if the slogan thing works just like a component I might be making a component with the div and any other html in it and the slogan inside that component, then calling the component in the template with a conditional php thing something like if (get_slogan('Announcement')!='none') get_component('Announcement') . In that case you would have to write none in the slogan to not show anything. The syntax is very likely wrong, lol, but someone clever will put it right.
Reply
#21
(2015-04-16, 07:06:26)davetest Wrote: What I'm trying to do is use in my template:
PHP Code:
<div><?php get_slogan('Announcement');?></div> 
But I need a php solution so that if the slogan has no content, the div tags will also not display. That way I don't get to apply any of the css attached to the div.
Can any php expert point me in the right direction?

hardly an 'expert' here, lol, but something like this, perhaps?
PHP Code:
<?php if(function_exists('get_slogan') && get_slogan('Announcement')) {
echo 
'<div>' get_slogan('Announcement') . '</div>';
}
?>
Reply
#22
(2015-04-16, 10:41:05)simplycrazy Wrote:
(2015-04-16, 07:06:26)davetest Wrote: What I'm trying to do is use in my template:

PHP Code:
<div><?php get_slogan('Announcement');?></div> 
But I need a php solution so that if the slogan has no content, the div tags will also not display. That way I don't get to apply any of the css attached to the div.
Can any php expert point me in the right direction?

hardly an 'expert' here, lol, but something like this, perhaps?

PHP Code:
<?php if(function_exists('get_slogan') && get_slogan('Announcement')) {
echo 
'<div>' get_slogan('Announcement') . '</div>';
}
?>
 Thanks for your input simplycrazy, but sadly all that goes is display the snippet content under all conditions and never displays the divs :-(
Reply
#23
(2015-04-16, 17:54:37)davetest Wrote: Thanks for your input simplycrazy, but sadly all that goes is display the snippet content under all conditions and never displays the divs :-(

add ,FALSE to the get_slogan() calls so they return instead of a echo default?

get_slogan('Announcement',FALSE)
Reply
#24
Maybe:
Code:
if (return_slogan()) { ...
Reply
#25
(2015-04-16, 10:41:05)simplycrazy Wrote: hardly an 'expert' here, lol, but something like this, perhaps?


PHP Code:
<?php if(function_exists('get_slogan') && get_slogan('Announcement')) {
echo 
'<div>' get_slogan('Announcement') . '</div>';
}
?>

Almost there: 

PHP Code:
<?php if(function_exists('return_slogan') && return_slogan('Announcement')) {
  
// will evaluate to TRUE if Announcement's text length > 0
 
 echo '<div>' return_slogan('Announcement') . '</div>';
 
 // or: echo '<div>'; get_slogan('Announcement'); echo '</div>';
}?>

The author of Slogans plugin didn't include a second $echo parameter in the get_slogan function (but that's fine, you can use return_slogan)
JFYI (& shameless self-promoting), you can also do this & more with Gs Custom Settings (although not I18n-enabled yet)
Reply




Users browsing this thread: 4 Guest(s)