Recent Topics

1 Oct 09, 2007 20:03    

My b2evolution Version: 1.9.x

Hi,

I have a plugin which includes the following code:

<h3>'.T_('something').'</h3>

Is there any other option to decide, which text I want to have to diplay on my blog than editing the plugin-php directly? I would like to write something to that effect e.g. in my _main.php or custom.css

Any ideas or is this not possible?

Thanks in advance,
Daniel

2 Oct 10, 2007 00:20

Can you be a little more specific? Which plugin?

3 Oct 10, 2007 07:36

Which plugin? Hmm, my own ;) the blogfever widget plugin for the German blog-syndication-service... http://plugins.b2evolution.net/index.php/2007/10/08/blogfever_plugin

The thing is, I know, how to change the php-plugin file to use as h3 headline whatever I want... but for all other users I would like to customize the headline as well as easily as possible.

So I had to type something as headline (see above), but I´m now searching for an option for all users to decide for there own headline...

Was this more understandable or even more confusing?

Trying to explain it with an example:

The default text is "something" and that´s fine for users 1, 2, and 3. User 4 wants to customize this headline into "somethingelse" and user 5 and 6 want to use "the-other-way-around"... simply possible by editing the plugin-php itself... but for potential users who don´t want to mess around with php-files directly despite "there own" in the custom skin directory [u]and[/u] to avoid that users have to modify my plugin directly (concerning the shown headline) every time I update it, I´m searching for a "simple" way in doing so only editing the files of your custom skin via the backoffice... Or is the only possibility to modify core files or of course the plugin-php itself?

4 Oct 10, 2007 08:53

You can add an configuration option to you plugin, to contain the desired headline, initialized with a suitable default ('something') in your example above. For this, you need to define a GetDefaulSettings() function inside your plugin, something like this:

function GetDefaultSettings()
{
  return array(
    'headline' => array(
      'label' => $this->T_('Default headline'),
      'type' => 'text',
      'defaultvalue' => 'something',
    ),
  );
}

Then you use

$this->Settings->get('headline')

to retrieve the value set by the user from the backoffice.

5 Oct 10, 2007 09:27

wd Austraico, (but I would call it 'Custom headline' rather than 'Default headline' B) )

If it's like a sidebar item you can pull it out of the plugin.

You might want to try with a variable in _main.php, but I am not sure if the scope of the variable reaches the plugin.
In _main.php:

$something = 'something';


In the plugin:

<h3>'.$something.'</h3>

But Austriaco's solution is much nicer. :p

Good luck

6 Oct 10, 2007 13:51

Thanks Austriaco, but I think I have done something wrong...

I´be integrated your function in my plufin between the function blogfever_plugin() and the function SkinTag($params) ... no error so far... but where exactly I have to include the customized headline?

I´ve tried

<?php $Plugins->call_by_code( 'blogfever_widget', array( ) ); ?>
<?php $this->Settings->get('Blogfever123'); ?>

but this does nothing changing... and

<?php $Plugins->call_by_code( 'blogfever_widget', array( $this->Settings->get('Blogfever123') ) ); ?>

produces error messages...

What exactly was your idea in implementing the customized headline?

7 Oct 10, 2007 13:57

@Afwas

<?php $BlogfeverTitel = 'Blogfever123'; ?>
<?php $Plugins->call_by_code( 'blogfever_widget', array( ) ); ?>

in the _main.php

with

<h3>'.$BlogfeverTitel.'</h3>

in my plugin, produces the folowing error message instead of a headline:


Notice: Undefined variable: BlogfeverTitel in /home/www/.../blog/plugins/_blogfever.plugin.php on line 46

Is sadly not orking either...

8 Oct 10, 2007 14:01

The function by Austriaco looks ok, you can place it before:

function SkinTag($params) {

Then you call it where the original line is:

if(!isset($params['title'])) $params['title'] = '<h3>'.T_('Blogfever').'</h3>';


becomes:

if(!isset($params['title'])) $params['title'] = '<h3>'.$this->Settings->get('headline').'</h3>';

Good luck

9 Oct 10, 2007 14:05

Ok Afwas, so far I can follow... but where (in the _main.php?) I include the user-selected-headline?

10 Oct 10, 2007 14:08

Daniel wrote:

@Afwas

in my plugin, produces the folowing error message instead of a headline:


Notice: Undefined variable: BlogfeverTitel in /home/www/.../blog/plugins/_blogfever.plugin.php on line 46

Is sadly not orking either...

Try:

global $BlogfeverTitel;


In the row with the var s.

11 Oct 10, 2007 14:11

Daniel wrote:

Ok Afwas, so far I can follow... but where (in the _main.php?) I include the user-selected-headline?

Austriaco's solution produces a textbox in the edit section of the plugin (backoffice->App settings->Plugins->BlogFever) where you can change the title.

12 Oct 10, 2007 14:24

Hey, this is cool... that´s the perfect way to simplify the headline customization! PERFECT! I can learn so much more from you... I know!! :D

Thank you both very much... I will mention you in the version history of my plugin, which I will officialize a little bit later that day... from home ;)

=> PROBLEM SOLVED :!:


Form is loading...