Recent Posts of Frog CMS in New ways to use snippets http://forum.madebyfrog.com/rss en-us 25 New ways to use snippets <p>I would do it the way philippe is recommending, as it seems to be the most flexible.</p> Wed, 10 Sep 2008 00:13:42 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2933 ajcates http://forum.madebyfrog.com/topic/427?page=1#post_2933 New ways to use snippets <p>@mvdkleijn &#8211; (very late reply!) &#8211; I do see the value of passing params to snippets &#8230; I&#8217;m not so sure what I would do with the Radiant version that AJ was originally asking about. <span class="caps">FWIW</span>! :)</p> Tue, 09 Sep 2008 17:26:16 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2923 David http://forum.madebyfrog.com/topic/427?page=1#post_2923 New ways to use snippets <p>I like this idea&#8230; though I would probably always call it snippetParams just to get a consistent and clear use of it.</p> Tue, 09 Sep 2008 15:43:28 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2914 mvdkleijn http://forum.madebyfrog.com/topic/427?page=1#post_2914 New ways to use snippets <p>by the way you can use what ever you want for the variable name like</p> <pre><code>$this-&gt;snippetContent = array( ... ); or $this-&gt;s = array( ... ); </code></pre> <p>but be carefull to use undefine variable, otherwise you can really crash Frog ;)</p> Mon, 08 Sep 2008 20:42:52 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2901 philippe http://forum.madebyfrog.com/topic/427?page=1#post_2901 New ways to use snippets <p>was a idea like that !! ;) sometime they are good sometime it&#8217;s just a idea like that ;)</p> <p>but yes this can be really usefull and can replace the need of one line part</p> Mon, 08 Sep 2008 20:21:55 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2898 philippe http://forum.madebyfrog.com/topic/427?page=1#post_2898 New ways to use snippets <p>interesting, philippe. doing something like that seems to obviate the need for parts in many situations&#8230;</p> Mon, 08 Sep 2008 19:57:36 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2897 ricks http://forum.madebyfrog.com/topic/427?page=1#post_2897 New ways to use snippets <p>or you can simply use someting like this in your page or layout : </p> <pre><code>&lt;?php $this-&gt;snippetParams = array( 'title' =&gt; 'my title', 'name' =&gt; 'Philippe' ); </code> <code>$this-&gt;includeSnippet('my-snippet'); ?&gt; </code></pre> <p>and then use this in the snippet:</p> <pre><code>&lt;?php echo $this-&gt;snippetParams['title']; ?&gt; </code></pre> Mon, 08 Sep 2008 19:44:00 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2895 philippe http://forum.madebyfrog.com/topic/427?page=1#post_2895 New ways to use snippets <p>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?</p> Fri, 15 Aug 2008 05:34:23 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2471 ajcates http://forum.madebyfrog.com/topic/427?page=1#post_2471 New ways to use snippets <p>Hmmm... I understand what you're trying to do...</p> <p>David, what do you as a "non-programmer" feel about this? :-p</p> Fri, 15 Aug 2008 05:32:18 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2470 mvdkleijn http://forum.madebyfrog.com/topic/427?page=1#post_2470 New ways to use snippets <pre><code>//Layout code &lt;?php $myArray['recentPosts'] = false; $myArray['blogRoll'] = true; $myArray['twitter'] = true; $this-&gt;includeSnippet('sidebar', $myArray); ?&gt; //sidebar snippet &lt;div id="sidebar"&gt; &lt;?php if($recentPosts) ?&gt; //code for recent posts &lt;?php endif ?&gt; &lt;?php if($blogRoll) ?&gt; //code for blog roll &lt;?php endif ?&gt; &lt;?php if($twitter) ?&gt; //code for twitter posts &lt;?php endif ?&gt; &lt;/div&gt; </code></pre> Fri, 15 Aug 2008 05:07:21 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2469 ajcates http://forum.madebyfrog.com/topic/427?page=1#post_2469 New ways to use snippets <p>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.</p> <p>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 &lt;?php $myArray['recentPosts'] = false; $myArray['blogRoll'] = true; $myArray['twitter'] = true; $this-&gt;includeSnippet('sidebar', $myArray); ?&gt; //sidebar snippet &lt;div id="sidebar"&gt; &lt;?php if($recentPosts) ?&gt; //code for recent posts &lt;?php endif ?&gt; &lt;?php if($blogRoll) ?&gt; //code for blog roll &lt;?php endif ?&gt; &lt;?php if($twitter) ?&gt; //code for twitter posts &lt;?php endif ?&gt; &lt;/div&gt;</p> Fri, 15 Aug 2008 05:04:03 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2468 ajcates http://forum.madebyfrog.com/topic/427?page=1#post_2468 New ways to use snippets <p>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? :-)</p> <p>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.</p> <p>But what do others here think about this? :-)</p> Fri, 15 Aug 2008 04:46:41 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2465 mvdkleijn http://forum.madebyfrog.com/topic/427?page=1#post_2465 New ways to use snippets <p>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.</p> <p>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.</p> Fri, 15 Aug 2008 04:38:40 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2461 ajcates http://forum.madebyfrog.com/topic/427?page=1#post_2461 New ways to use snippets <p>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.</p> <p>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?)</p> Fri, 15 Aug 2008 04:29:45 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2459 mvdkleijn http://forum.madebyfrog.com/topic/427?page=1#post_2459 New ways to use snippets <p>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.</p> Thu, 14 Aug 2008 15:59:57 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2440 ajcates http://forum.madebyfrog.com/topic/427?page=1#post_2440 New ways to use snippets <p>What if I want to put in html heavy things into my variable should I just use EOF??</p> Thu, 14 Aug 2008 13:52:51 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2437 ajcates http://forum.madebyfrog.com/topic/427?page=1#post_2437 New ways to use snippets <p>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:</p> <pre><code> &lt;?php $this-&gt;includeSnippet('the_name_of_the_snippet', $parameter) ?&gt; </code></pre> <p>or</p> <pre><code> &lt;?php $this-&gt;includeSnippet('the_name_of_the_snippet', 'to be included in the snippet') ?&gt; </code></pre> <p>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.</p> <p>The question is whether we would want to implement something like this and whether we would want to do it in this manner?</p> <p>What would you use this for ajcates?</p> Thu, 14 Aug 2008 09:18:41 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2432 mvdkleijn http://forum.madebyfrog.com/topic/427?page=1#post_2432 New ways to use snippets <p><a href="http://radiantcms.org/blog/archives/2008/08/13/new-ways-to-use-snippets/">New radiant snippets</a></p> <p>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.</p> Thu, 14 Aug 2008 00:36:17 +0000 http://forum.madebyfrog.com/topic/427?page=1#post_2423 ajcates http://forum.madebyfrog.com/topic/427?page=1#post_2423