New ways to use snippets
|
Aug 14, 2008 00:36
44 posts
|
I was wondering if there was a way to enable this feature in Frog. It would be really handy, I am not sure the best to go about using it. Maybe make a variable call inside your snippet to load in the external text. |
|
Aug 14, 2008 09:18
396 posts
|
actually... that isn't too difficult to implement I suspect... translated to Frog's snippets structure, the fastest way to implement this would be to call a snippet like this:
or
I don't think the includeSnippet function has any parameters at the moment, so that wouldn't clash but I'd have to check tonight. The question is whether we would want to implement something like this and whether we would want to do it in this manner? What would you use this for ajcates? |
|
Aug 14, 2008 13:52
44 posts
|
What if I want to put in html heavy things into my variable should I just use EOF?? |
|
Aug 14, 2008 15:59
44 posts
|
Actually it would be better if we could have multiple variables to be able to be put into the snippet call and have a array load up in the snippet this way we could call multiple items. It would actually make it more powerful then radiant's version. |
|
Aug 15, 2008 04:29
396 posts
|
If we're going to do something like this, I think we shouldn't put HTML heavy things in there... what would be the point? Then it would be better to simply create another snippet. When I look at the example in Radiant, they use it to simplify the layout of a list for example. I'm not seeing a particularly interesting use case here.... (I actually feel that this might needlessly complicate Frog?) |
|
Aug 15, 2008 04:38
44 posts
|
How would it complicate frog? It would work just the way it does currently except that it would have more functionally. It can stay backwards compatible. In the example they use it to make some div soup for some rounded corners. It would be better manageability wise to create a new snippet if you do plan to insert html into your snippet, flexibility wise I think that anything after the 1st parameter in includeSnippet should be passed on to the snippet. |
|
Aug 15, 2008 04:46
396 posts
|
It blurs the line between content editor and site developer I think... BUT I'm not the only one here and I don't have anything AGAINST the idea, so.... what do other people think? :-) On the implementation side of things... Who's the target audience of this functionality? Is the content editor going to use it or is the site developer/admin going to use it? If the user doesn't know anything about PHP, this might be too complicated already... If the user does know PHP, I'd prefer passing an array of parameters to the includeSnippet function. But what do others here think about this? :-) |
|
Aug 15, 2008 05:04
44 posts
|
I have always thought of frog as a bastard child of a web framework and CMS. But I see where you are coming from the actual content users point of view. I believe that if they are going to managing content on a Frog site that they should not see any php code. This new way of using snippets would be very helpful when you are making themes, and setting up like a sidebar. I would use it in this way with a sidebar: //Layout code <?php $myArray['recentPosts'] = false; $myArray['blogRoll'] = true; $myArray['twitter'] = true; $this->includeSnippet('sidebar', $myArray); ?> //sidebar snippet <div id="sidebar"> <?php if($recentPosts) ?> //code for recent posts <?php endif ?> <?php if($blogRoll) ?> //code for blog roll <?php endif ?> <?php if($twitter) ?> //code for twitter posts <?php endif ?> </div> |
|
Aug 15, 2008 05:07
44 posts
|
|
|
Aug 15, 2008 05:32
396 posts
|
Hmmm... I understand what you're trying to do... David, what do you as a "non-programmer" feel about this? :-p |
|
Aug 15, 2008 05:34
44 posts
|
Also lets say if I made the changes my self to the snippet code in the core, is there any way I can submit my changes to like a code repository for review? |
|
Sep 8, 2008 19:44
382 posts
|
or you can simply use someting like this in your page or layout :
and then use this in the snippet: |
|
Sep 8, 2008 19:57
284 posts
|
interesting, philippe. doing something like that seems to obviate the need for parts in many situations… |
|
Sep 8, 2008 20:21
382 posts
|
was a idea like that !! ;) sometime they are good sometime it’s just a idea like that ;) but yes this can be really usefull and can replace the need of one line part |
|
Sep 8, 2008 20:42
382 posts
|
by the way you can use what ever you want for the variable name like
but be carefull to use undefine variable, otherwise you can really crash Frog ;) |
|
Sep 9, 2008 15:43
396 posts
|
I like this idea… though I would probably always call it snippetParams just to get a consistent and clear use of it. |
|
Sep 9, 2008 17:26
818 posts
|
@mvdkleijn – (very late reply!) – I do see the value of passing params to snippets … I’m not so sure what I would do with the Radiant version that AJ was originally asking about. FWIW! :) |
|
Sep 10, 2008 00:13
44 posts
|
I would do it the way philippe is recommending, as it seems to be the most flexible. |