Posts: 2,094
Threads: 54
Joined: Jan 2011
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.
Posts: 53
Threads: 1
Joined: Nov 2009
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.
Posts: 3
Threads: 1
Joined: Apr 2011
2011-04-30, 06:21:52
(This post was last modified: 2011-04-30, 06:22:16 by khan066611199.)
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
Posts: 2,094
Threads: 54
Joined: Jan 2011
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.
Posts: 3
Threads: 0
Joined: May 2010
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
Posts: 1
Threads: 0
Joined: May 2011
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.
Posts: 2,094
Threads: 54
Joined: Jan 2011
2011-05-26, 23:40:12
(This post was last modified: 2011-05-27, 01:04:13 by nime.)
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.
Posts: 524
Threads: 48
Joined: Mar 2011
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.
Posts: 161
Threads: 6
Joined: Jan 2010
Am I right in thinking this plugin doesn't integrate with I18N Custom Fields out of the box?
Posts: 2,094
Threads: 54
Joined: Jan 2011
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.
Posts: 161
Threads: 6
Joined: Jan 2010
2011-06-06, 14:35:32
(This post was last modified: 2011-06-06, 14:50:22 by kuba.sanitrak.)
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.
Posts: 2,094
Threads: 54
Joined: Jan 2011
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.
Posts: 45
Threads: 5
Joined: Feb 2011
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...
Posts: 524
Threads: 48
Joined: Mar 2011
Replace component_name with test and it should work flawlessly :-)
{% test %}
Posts: 45
Threads: 5
Joined: Feb 2011
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...
Posts: 110
Threads: 3
Joined: Sep 2010
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..
Posts: 49
Threads: 8
Joined: Oct 2011
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:
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.
Posts: 2,094
Threads: 54
Joined: Jan 2011
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 %)
Posts: 110
Threads: 3
Joined: Sep 2010
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
Posts: 2,094
Threads: 54
Joined: Jan 2011
Correction: you need to use curly brackets:
Code: {% music_player beethoven_eroica %}
Posts: 110
Threads: 3
Joined: Sep 2010
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
Posts: 2,094
Threads: 54
Joined: Jan 2011
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.
Posts: 110
Threads: 3
Joined: Sep 2010
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....
Posts: 110
Threads: 3
Joined: Sep 2010
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:
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!
Posts: 2,094
Threads: 54
Joined: Jan 2011
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...
|