Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DynPages plugin
#1
I've created the DynPages plugin (http://get-simple.info/extend/plugin/dynpages/81/) which allows place holders on a page to include a component. It is also possible to pass parameters to the component. As a component can include php-Code, you can thus easily include dynamic fragments on your pages.

For examples see http://mvlcek.bplaced.net/get-simple/dynpages/.

The plugin is similar to the RePlacer plugin, but uses components instead of additional "RePlace" files and allows for parameters passed to the included component.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#2
Thanks for this plugin. I'm using it now to avoid having to use the exec_php plugin, because the editor is messing the php code up.

Working nicely so far. But it's not possible to use e. g. "-" in the component name. Took me a while to figure this out.
Reply
#3
mvlcek Wrote:I've created the DynPages plugin (http://get-simple.info/extend/plugin/dynpages/81/) which allows place holders on a page to include a component. It is also possible to pass parameters to the component. As a component can include php-Code, you can thus easily include dynamic fragments on your pages.

For examples see http://mvlcek.bplaced.net/get-simple/dynpages/.

The plugin is similar to the RePlacer plugin, but uses components instead of additional "RePlace" files and allows for parameters passed to the included component.

How can you pass a string with a space as a parameter? I tried both encapsulating it in single or double quotes and it didn't work
Reply
#4
ash Wrote:How can you pass a string with a space as a parameter? I tried both encapsulating it in single or double quotes and it didn't work

In the new version 0.7 you can enclose the parameters in single or double quotes.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#5
Thanks for this plugin mvlcek. One small fix I had to make: your regular expression doesn't match hyphens within component names (only underscores). The default behaviour of Get Simple is to replace spaces in component titles with hyphens, so it'll be quite a common character to appear.

Just changing [a-zA-Z0-9_] on line 42 in dynpages.php to [a-zA-Z0-9_-] did the trick.

Thanks,

Sam
Reply
#6
This plugin is very helpful to me because i can simplify my work, If I want to embed dynamic code,php, forms or javascript on a page I can use this.If i like to change the lay out of my website i can do it as easy as step 1,2,3..great plugin.
Reply
#7
samrayner Wrote:Thanks for this plugin mvlcek. One small fix I had to make: your regular expression doesn't match hyphens within component names (only underscores). The default behaviour of Get Simple is to replace spaces in component titles with hyphens, so it'll be quite a common character to appear.

Just changing [a-zA-Z0-9_] on line 42 in dynpages.php to [a-zA-Z0-9_-] did the trick.

Thanks,

Sam

Thanks for the bug report. I created it for GS 2.03 and the behaviour then was to remove blanks (as far as I can remember).

Fixed in DynPages version 0.7.1.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#8
Thanks for this plugin,

I've successfully used it to embed calls of the Simple Page Content plugin within a page itself. No creating a new template or tweaking the default.

Very nice.
Reply
#9
Am I right in thinking this plugin doesn't integrate with I18N Custom Fields out of the box?
Modern UI Admin for GetSimple
Watch the demo. Install this plugin. Use this CSS. Enjoy.
Reply
#10
sal Wrote:Am I right in thinking this plugin doesn't integrate with I18N Custom Fields out of the box?
What do you mean? There should be no problems using both of them.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#11
mvlcek Wrote:
sal Wrote:Am I right in thinking this plugin doesn't integrate with I18N Custom Fields out of the box?
What do you mean? There should be no problems using both of them.
I mean you're not able to use placeholders in custom fields if using both this plugin and I18N Custom Fields. If there was a hook for custom fields you could run your filter on that.

Code:
add_filter('content','dynpages_replace');
add_filter('custom_fields','dynpages_replace');

The reason I actually asked is because I was implementing the I18N Search plugin and found I couldn't use the (% searchform %) placeholder in a sidebar custom field, so the same hook could be used there too, with extra checks for the Custom Fields plugin being present if the hooks system doesn't already account for this.

Code:
add_filter('content','i18n_search_replace');
add_filter('custom_fields','i18n_search_replace');

That said, it's no where near that easy, I'm sure.
Modern UI Admin for GetSimple
Watch the demo. Install this plugin. Use this CSS. Enjoy.
Reply
#12
sal Wrote:I mean you're not able to use placeholders in custom fields if using both this plugin and I18N Custom Fields.

I18N Custom Fields version 1.7 calls all content filters for WYSIWYG fields. Thus most plugins replacing place holders should work, as long as they don't also add headers, etc.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#13
Mvleck - Do I need any additional plugin to make this work? I've uploaded the dynpages.php file to the plug-in folder, created a "test" component (with simple text-only message), and added:

{% component_name test %}

To my WYSIWYG page content. When I view the page live, I get the placeholder code text above instead of the component content. Is there something I'm missing? All my other plugins are working correctly (only using hitcount and user-management at the moment) and I'm not showing any errors I can see...
Reply
#14
Replace component_name with test and it should work flawlessly :-)

{% test %}
Reply
#15
polyfragmented Wrote:Replace component_name with test and it should work flawlessly :-)

{% test %}

Yep. Thanks! I knew I was working too late at night again...
Reply
#16
Hi -

I was wondering how to pass parameters to a component using the dynpages plugin;

i'm using an html5 player which uses this code for the player:

Code:
<audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/audio_file.mp3" />
          <source type="audio/ogg" src="/data/uploads/audio_file.ogg" />
    </audio>

so i set this up as a component and am loading it into the article with dynpages;

i would like to be able to put a placeholder where it says 'audio_file', so that i can use one component and then have it load different audio files by specifying the audio file name in the tag...

thanks in advance for any info on how to do this...i tried to read the instructions about using global arguments, but it seems to use php and since my component doesn't have any php i wasn't sure if this is possible..
Reply
#17
alienee2 Wrote:Hi -

I was wondering how to pass parameters to a component using the dynpages plugin;

i'm using an html5 player which uses this code for the player:

Code:
<audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/audio_file.mp3" />
          <source type="audio/ogg" src="/data/uploads/audio_file.ogg" />
    </audio>

so i set this up as a component and am loading it into the article with dynpages;

i would like to be able to put a placeholder where it says 'audio_file', so that i can use one component and then have it load different audio files by specifying the audio file name in the tag...

thanks in advance for any info on how to do this...i tried to read the instructions about using global arguments, but it seems to use php and since my component doesn't have any php i wasn't sure if this is possible..

Try this:

- Install the DynPages and I18N Custom Fields plugins.
- Go to the Plugins tab in Admin. Create a new custom field:

Name: music_file
Label: Music File
Type: Text field

- Create a theme component. Name it "music_player".
- Enter this for the component's code:

Code:
<audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/<?php get_custom_field('music_file'); ?>.mp3" />
          <source type="audio/ogg" src="/data/uploads/<?php get_custom_field('music_file'); ?>.ogg" />
</audio>

- Now when you create a page in GetSimple complete the custom field Music File with the filename's name excluding the extension (i.e., song1.mp3 would be "song1").
- In the WYSIWYG editor enter:

Code:
{% music_player %}

This should do it. I think. I haven't tried this I'm just following what I think would be a sequence that would work.
Reply
#18
alienee2 Wrote:Hi -

I was wondering how to pass parameters to a component using the dynpages plugin;

i'm using an html5 player which uses this code for the player:

Code:
<audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/audio_file.mp3" />
          <source type="audio/ogg" src="/data/uploads/audio_file.ogg" />
    </audio>

so i set this up as a component and am loading it into the article with dynpages;

i would like to be able to put a placeholder where it says 'audio_file', so that i can use one component and then have it load different audio files by specifying the audio file name in the tag...

thanks in advance for any info on how to do this...i tried to read the instructions about using global arguments, but it seems to use php and since my component doesn't have any php i wasn't sure if this is possible..

Just create the component (named "music_player") as:
Code:
<?php global $args; ?>
   <audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/<?php echo $args[0]; ?>.mp3" />
          <source type="audio/ogg" src="/data/uploads/<?php echo $args[0]; ?>.ogg" />
    </audio>
and call it from your page with e.g.
Code:
(% music_player beethoven_eroica %)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#19
mvlcek Wrote:
alienee2 Wrote:Hi -

I was wondering how to pass parameters to a component using the dynpages plugin;

i'm using an html5 player which uses this code for the player:

Code:
<audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/audio_file.mp3" />
          <source type="audio/ogg" src="/data/uploads/audio_file.ogg" />
    </audio>

so i set this up as a component and am loading it into the article with dynpages;

i would like to be able to put a placeholder where it says 'audio_file', so that i can use one component and then have it load different audio files by specifying the audio file name in the tag...

thanks in advance for any info on how to do this...i tried to read the instructions about using global arguments, but it seems to use php and since my component doesn't have any php i wasn't sure if this is possible..

Just create the component (named "music_player") as:
Code:
<?php global $args; ?>
   <audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/<?php echo $args[0]; ?>.mp3" />
          <source type="audio/ogg" src="/data/uploads/<?php echo $args[0]; ?>.ogg" />
    </audio>
and call it from your page with e.g.
Code:
(% music_player beethoven_eroica %)

OK, thanks so much for the code!....though for some reason this is not working.... when the page renders, it is not putting in the argument, so the file path is looking like /data/uploads/.mp3

-marc
Reply
#20
Correction: you need to use curly brackets:
Code:
{% music_player beethoven_eroica %}
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#21
mvlcek Wrote:Correction: you need to use curly brackets:
Code:
{% music_player beethoven_eroica %}

even with the curly brackets, the variable doesn't get inserted... still shows as /data/uploads/.ogg
Reply
#22
alienee2 Wrote:
mvlcek Wrote:Correction: you need to use curly brackets:
Code:
{% music_player beethoven_eroica %}

even with the curly brackets, the variable doesn't get inserted... still shows as /data/uploads/.ogg

If you did get the <audio ...> code with (% music_player beethoven_eroica %), you are confusing something - this can't happen.
Are you sure you are testing the correct page - and not a page with just {% music_player %} on it? For me it works perfectly.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#23
Here is the component code:

Code:
<?php global $args; ?>
   <audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/<?php echo $args[0]; ?>.mp3" />
          <source type="audio/ogg" src="/data/uploads/<?php echo $args[0]; ?>.ogg" />
    </audio>

and the component is called audio-player
the audio files are named sleepers_awake.mp3 and sleepers_awake.ogg

Here is the tag i'm using:

Code:
{% audio-player sleepers_awake %}

here is the url where i'm using the code: http://www.weddingmusicensembles.com/

the first player is the one using this code, and the output is looking like this:

Code:
<audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/.mp3" />
          <source type="audio/ogg" src="/data/uploads/.ogg" />
    </audio>

the subsequent players are each using a separate component where the audio file path is part of the component...

thanks again for your help...not sure why this isn't working for me....
Reply
#24
jyoz22 Wrote:
alienee2 Wrote:Hi -

I was wondering how to pass parameters to a component using the dynpages plugin;

i'm using an html5 player which uses this code for the player:

Code:
<audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/audio_file.mp3" />
          <source type="audio/ogg" src="/data/uploads/audio_file.ogg" />
    </audio>

so i set this up as a component and am loading it into the article with dynpages;

i would like to be able to put a placeholder where it says 'audio_file', so that i can use one component and then have it load different audio files by specifying the audio file name in the tag...

thanks in advance for any info on how to do this...i tried to read the instructions about using global arguments, but it seems to use php and since my component doesn't have any php i wasn't sure if this is possible..

Try this:

- Install the DynPages and I18N Custom Fields plugins.
- Go to the Plugins tab in Admin. Create a new custom field:

Name: music_file
Label: Music File
Type: Text field

- Create a theme component. Name it "music_player".
- Enter this for the component's code:

Code:
<audio class="AudioPlayerV1">
          <source type="audio/mpeg" src="/data/uploads/<?php get_custom_field('music_file'); ?>.mp3" />
          <source type="audio/ogg" src="/data/uploads/<?php get_custom_field('music_file'); ?>.ogg" />
</audio>

- Now when you create a page in GetSimple complete the custom field Music File with the filename's name excluding the extension (i.e., song1.mp3 would be "song1").
- In the WYSIWYG editor enter:

Code:
{% music_player %}

This should do it. I think. I haven't tried this I'm just following what I think would be a sequence that would work.

that's a very cool idea; though this would limit you to one audio track per page...thank you for the suggestion!
Reply
#25
alienee2 Wrote:thanks again for your help...not sure why this isn't working for me....

I don't have any idea either - you are using the newest version of DynPages, aren't you?
Are you using I18N, too? Newest version?
There was a combination of versions of DynPages and I18N that didn't work...
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 1 Guest(s)
Free HDTV Channels Residential Solar Panels