<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: WPAlchemy MetaBox: Filtering and Repeating Fields	</title>
	<atom:link href="https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/</link>
	<description>Practical Real World Web Development</description>
	<lastBuildDate>Wed, 30 Sep 2015 19:40:13 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>
		By: Otto Rask		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-26671</link>

		<dc:creator><![CDATA[Otto Rask]]></dc:creator>
		<pubDate>Tue, 08 Jan 2013 11:07:33 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-26671</guid>

					<description><![CDATA[@Dimas: Okay, thanks for the info! I&#039;ll see if I can manage some other solution to this in the meantime. :)]]></description>
			<content:encoded><![CDATA[<p>@Dimas: Okay, thanks for the info! I&#8217;ll see if I can manage some other solution to this in the meantime. 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dimas		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-26663</link>

		<dc:creator><![CDATA[Dimas]]></dc:creator>
		<pubDate>Mon, 07 Jan 2013 16:12:46 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-26663</guid>

					<description><![CDATA[@Otto, at the moment there isn&#039;t a way to do nested repeating fields. I&#039;ve started a working on a solution and will try to have something available soon.]]></description>
			<content:encoded><![CDATA[<p>@Otto, at the moment there isn&#8217;t a way to do nested repeating fields. I&#8217;ve started a working on a solution and will try to have something available soon.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Otto Rask		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-26660</link>

		<dc:creator><![CDATA[Otto Rask]]></dc:creator>
		<pubDate>Mon, 07 Jan 2013 13:47:27 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-26660</guid>

					<description><![CDATA[Hello! Considering repeating fields:

I&#039;ve been using WPAlchemy on sites for a while now without problems. Now I&#039;ve stumbled upon a problem I can&#039;t seem to solve properly.

Is it possible to nest two or more &#039;have_fields_and_multi&#039; loops? Every time I insert one into another the script breaks and creates an infinite loop with incorrect field nesting (it keeps creating the same elements inside each instance of itself). In pseudo-code my implementation looks like this:


while ( $mb -&#062; have_fields_and_multi( &#039;foo&#039; ) ) {
    // Open a new container for a parent item listing
    // e.g. a category of sorts. These should be able
    // to be added as the user wishes.

    while ( $mb -&#062; have_fields_and_multi( &#039;bar&#039; ) ) {
        // Make repeating fields inside the parent
        // category loop.
    } // child loop

} // parent loop


(I&#039;ve properly inserted group opens and closes, also the add/delete buttons in their correct locations.)

This creates an infinite loop and the controls are not working properly (e.g. the inner loop has a &#039;dodelete&#039; -button, but it removes everything including the parent loop in its entirety).

Is there any workaround to get this functioning properly or should I try some other approach?]]></description>
			<content:encoded><![CDATA[<p>Hello! Considering repeating fields:</p>
<p>I&#8217;ve been using WPAlchemy on sites for a while now without problems. Now I&#8217;ve stumbled upon a problem I can&#8217;t seem to solve properly.</p>
<p>Is it possible to nest two or more &#8216;have_fields_and_multi&#8217; loops? Every time I insert one into another the script breaks and creates an infinite loop with incorrect field nesting (it keeps creating the same elements inside each instance of itself). In pseudo-code my implementation looks like this:</p>
<p>while ( $mb -&gt; have_fields_and_multi( &#8216;foo&#8217; ) ) {<br />
    // Open a new container for a parent item listing<br />
    // e.g. a category of sorts. These should be able<br />
    // to be added as the user wishes.</p>
<p>    while ( $mb -&gt; have_fields_and_multi( &#8216;bar&#8217; ) ) {<br />
        // Make repeating fields inside the parent<br />
        // category loop.<br />
    } // child loop</p>
<p>} // parent loop</p>
<p>(I&#8217;ve properly inserted group opens and closes, also the add/delete buttons in their correct locations.)</p>
<p>This creates an infinite loop and the controls are not working properly (e.g. the inner loop has a &#8216;dodelete&#8217; -button, but it removes everything including the parent loop in its entirety).</p>
<p>Is there any workaround to get this functioning properly or should I try some other approach?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: James Fishwick		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-5493</link>

		<dc:creator><![CDATA[James Fishwick]]></dc:creator>
		<pubDate>Sat, 30 Oct 2010 14:47:47 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-5493</guid>

					<description><![CDATA[Excellent work here; I&#039;ll just be throwing out the meta_box functions in all the themes I modify and using yours from here on out. 

Could you help me troubleshoot something? I&#039;m pretty much following your example exactly for an endlessly repeating field, but the &quot;Add&quot; button isn&#039;t actually replicating the field.

Here is how I create the meta_box instance:
&lt;code&gt;
$sidebar_images_metabox = new WPAlchemy_MetaBox(array
(
	&#039;id&#039; =&#062; &#039;_sidebar_images_meta&#039;, 
	&#039;title&#039; =&#062; &#039;Sidebar Images&#039;,
	&#039;template&#039; =&#062; TEMPLATEPATH . &#039;/custom/sidebar_images_meta.php&#039;,
	&#039;types&#039; =&#062; array(&#039;page&#039;),
	&#039;exclude_template&#039; =&#062; &#039;index.php&#039;,
	&#039;priority&#039; =&#062; &#039;high&#039;
));
&lt;/code&gt;

Here is my template:

&lt;pre lang=&quot;php&quot; line=&quot;&quot; escaped=&quot;true&quot;&gt;
&#060;?php while($mb-&#062;have_fields_and_multi(&#039;sidebar_image&#039;)): ?&#062;

&#060;?php $mb-&#062;the_group_open(); ?&#062;
 
	&#060;label&#062;The Image Path&#060;/label&#062;
 
	&#060;p&#062;
		&#060;?php $mb-&#062;the_field(&#039;src&#039;); ?&#062;
		&#060;input type=&#034;text&#034; name=&#034;&#060;?php $mb-&#062;the_name(); ?&#062;&#034; value=&#034;&#060;?php $mb-&#062;the_value(); ?&#062;&#034;/&#062;
		&#060;span&#062;Using the &#034;&#060;em&#062;Add an Image&#060;/em&#062;&#034; button, Upload an image and paste the URL here. Images will be resized automatically.&#060;/span&#062;
	&#060;/p&#062;
 
	&#060;label&#062;ALT Description &#060;span&#062;(optional)&#060;/span&#062;&#060;/label&#062;
 
	&#060;p&#062;
		&#060;?php $mb-&#062;the_field(&#039;alt&#039;); ?&#062;
		&#060;textarea name=&#034;&#060;?php $mb-&#062;the_name(); ?&#062;&#034; rows=&#034;3&#034;&#062;&#060;?php $mb-&#062;the_value(); ?&#062;&#060;/textarea&#062;
		&#060;span&#062;Enter in an ALT description.&#060;/span&#062;
	&#060;/p&#062;

&#060;/div&#062;
&#060;?php $mb-&#062;the_group_close(); ?&#062;
&#060;?php endwhile; ?&#062;
 
&#060;p style=&#034;margin-bottom:15px; padding-top:5px;&#034;&#062;&#060;a href=&#034;#&#034; class=&#034;docopy-sidebar_image button&#034;&#062;Add Anoter Image&#060;/a&#062;&#060;/p&#062;
&lt;/pre&gt;

Again, just can&#039;t get the field to replicate when clicking &quot;Add Another Image.&quot; Any ideas?]]></description>
			<content:encoded><![CDATA[<p>Excellent work here; I&#8217;ll just be throwing out the meta_box functions in all the themes I modify and using yours from here on out. </p>
<p>Could you help me troubleshoot something? I&#8217;m pretty much following your example exactly for an endlessly repeating field, but the &#8220;Add&#8221; button isn&#8217;t actually replicating the field.</p>
<p>Here is how I create the meta_box instance:<br />
<code><br />
$sidebar_images_metabox = new WPAlchemy_MetaBox(array<br />
(<br />
	'id' =&gt; '_sidebar_images_meta',<br />
	'title' =&gt; 'Sidebar Images',<br />
	'template' =&gt; TEMPLATEPATH . '/custom/sidebar_images_meta.php',<br />
	'types' =&gt; array('page'),<br />
	'exclude_template' =&gt; 'index.php',<br />
	'priority' =&gt; 'high'<br />
));<br />
</code></p>
<p>Here is my template:</p>
<pre lang="php" line="" escaped="true">
&lt;?php while($mb-&gt;have_fields_and_multi('sidebar_image')): ?&gt;

&lt;?php $mb-&gt;the_group_open(); ?&gt;
 
	&lt;label&gt;The Image Path&lt;/label&gt;
 
	&lt;p&gt;
		&lt;?php $mb-&gt;the_field('src'); ?&gt;
		&lt;input type=&quot;text&quot; name=&quot;&lt;?php $mb-&gt;the_name(); ?&gt;&quot; value=&quot;&lt;?php $mb-&gt;the_value(); ?&gt;&quot;/&gt;
		&lt;span&gt;Using the &quot;&lt;em&gt;Add an Image&lt;/em&gt;&quot; button, Upload an image and paste the URL here. Images will be resized automatically.&lt;/span&gt;
	&lt;/p&gt;
 
	&lt;label&gt;ALT Description &lt;span&gt;(optional)&lt;/span&gt;&lt;/label&gt;
 
	&lt;p&gt;
		&lt;?php $mb-&gt;the_field('alt'); ?&gt;
		&lt;textarea name=&quot;&lt;?php $mb-&gt;the_name(); ?&gt;&quot; rows=&quot;3&quot;&gt;&lt;?php $mb-&gt;the_value(); ?&gt;&lt;/textarea&gt;
		&lt;span&gt;Enter in an ALT description.&lt;/span&gt;
	&lt;/p&gt;

&lt;/div&gt;
&lt;?php $mb-&gt;the_group_close(); ?&gt;
&lt;?php endwhile; ?&gt;
 
&lt;p style=&quot;margin-bottom:15px; padding-top:5px;&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;docopy-sidebar_image button&quot;&gt;Add Anoter Image&lt;/a&gt;&lt;/p&gt;
</pre>
<p>Again, just can&#8217;t get the field to replicate when clicking &#8220;Add Another Image.&#8221; Any ideas?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dimas		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-4726</link>

		<dc:creator><![CDATA[Dimas]]></dc:creator>
		<pubDate>Wed, 13 Oct 2010 05:20:50 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-4726</guid>

					<description><![CDATA[@daniele, the code has definitely evolved and has become more stable, the code is available on github and I make adjustments as needed. I use if in my own production code. 

There currently isn&#039;t a discussion group for the code, but I am looking into something better than the WordPress commenting system for discussion. For now you can post your comments and questions on the &lt;a href=&quot;/wpalchemy-metabox/&quot; rel=&quot;nofollow&quot;&gt;wpalchemy&lt;/a&gt; page.]]></description>
			<content:encoded><![CDATA[<p>@daniele, the code has definitely evolved and has become more stable, the code is available on github and I make adjustments as needed. I use if in my own production code. </p>
<p>There currently isn&#8217;t a discussion group for the code, but I am looking into something better than the WordPress commenting system for discussion. For now you can post your comments and questions on the <a href="/wpalchemy-metabox/" rel="nofollow">wpalchemy</a> page.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: daniele m		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-4719</link>

		<dc:creator><![CDATA[daniele m]]></dc:creator>
		<pubDate>Tue, 12 Oct 2010 23:36:42 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-4719</guid>

					<description><![CDATA[nice library!
there are know bugs/issues?
ps
 do you have a google group?]]></description>
			<content:encoded><![CDATA[<p>nice library!<br />
there are know bugs/issues?<br />
ps<br />
 do you have a google group?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dimas		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-2079</link>

		<dc:creator><![CDATA[Dimas]]></dc:creator>
		<pubDate>Tue, 06 Jul 2010 15:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-2079</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-2077&quot;&gt;Horia&lt;/a&gt;.

Horia, I think your pretty close and seems like you already know what the solution will be, try something like:

&lt;pre&gt;
&#060;?php while($mb-&gt;have_fields(&#039;book&#039;,sizeof($the_books))): ?&gt;

	&#060;?php $the_book = $the_books[$mb-&gt;get_the_index()]; ?&gt;

	&#060;input type=&quot;checkbox&quot; name=&quot;&#060;?php $mb-&gt;the_name(); ?&gt;&quot; id=&quot;&#060;?php $mb-&gt;the_name(); ?&gt;&quot; value=&quot;&#060;?php echo $the_book-&gt;name; ?&gt;&quot;&#060;?php if($mb-&gt;is_value($the_book-&gt;name)) echo &#039; checked=&quot;checked&quot;&#039;; ?&gt;/&gt;
		&#060;label for=&quot;&#060;?php $mb-&gt;the_name(); ?&gt;&quot;&gt;&#060;?php echo $the_book-&gt;name; ?&gt;&lt;/label&gt;

&#060;?php endwhile; ?&gt;
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-2077">Horia</a>.</p>
<p>Horia, I think your pretty close and seems like you already know what the solution will be, try something like:</p>
<pre>
&lt;?php while($mb->have_fields('book',sizeof($the_books))): ?>

	&lt;?php $the_book = $the_books[$mb->get_the_index()]; ?>

	&lt;input type="checkbox" name="&lt;?php $mb->the_name(); ?>" id="&lt;?php $mb->the_name(); ?>" value="&lt;?php echo $the_book->name; ?>"&lt;?php if($mb->is_value($the_book->name)) echo ' checked="checked"'; ?>/>
		&lt;label for="&lt;?php $mb->the_name(); ?>">&lt;?php echo $the_book->name; ?>

&lt;?php endwhile; ?>
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Horia		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-2077</link>

		<dc:creator><![CDATA[Horia]]></dc:creator>
		<pubDate>Tue, 06 Jul 2010 14:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-2077</guid>

					<description><![CDATA[Hi Dimas, I am using WPAlchemy and I love it, but I really don&#039;t know how to do this (because I am not a developer) :
I am trying to create a metabox with a list of books on a custom post type named &quot;Authors&quot;, so the user can check the books the author wrote.

I take the list of books from the db, store them in &lt;code&gt;$the_books&lt;/code&gt; array and try to create a checkbox and a label for every book using WPAlchemy loop : 
&lt;code&gt;while($metabox-&#062;have_fields(&#039;book&#039;, sizeof($the_books))): &lt;/code&gt;

Perhaps my thinking here is wrong, but how would you create something like this ?

When I check a book and update page, the value is saved fine and I can read it fine on the frontend, but I can&#039;t make it display right in the admin. The problem I think is that when I create this inputs and labels, I use &lt;code&gt;$metabox-&#062;the_name()&lt;/code&gt; but can&#039;t use &lt;code&gt;$metabox-&#062;the_value()&lt;/code&gt; because I have to display the name of the books from the array : &lt;code&gt;$the_books[$count_books]-&#062;name;&lt;/code&gt;.

Hope you understood the problem and let me know if you think this is possible.
Thank you.

Here is the full code I am using in the metabox template :

&lt;pre&gt;
get_results(&#039;SELECT name FROM wp_wpsc_product_list WHERE active = 1 AND publish = 1&#039;);
?&#062;

have_fields(&#039;book&#039;, sizeof($the_books))): ?&#062;
	
    	&#060;input type=&#034;checkbox&#034; name=&#034;the_name(); ?&#062;&quot; id=&quot;the_name(); ?&#062;&quot; value=&quot;name; ?&#062;&quot; get_the_value()) echo &#039; checked=&quot;checked&quot;&#039;; ?&#062; /&#062;
        &#060;label for=&#034;the_name(); ?&#062;&quot;&#062;name; ?&#062; get_the_value()) echo &#039;value= &#039;.$metabox-&#062;get_the_value(); ?&#062;

&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>Hi Dimas, I am using WPAlchemy and I love it, but I really don&#8217;t know how to do this (because I am not a developer) :<br />
I am trying to create a metabox with a list of books on a custom post type named &#8220;Authors&#8221;, so the user can check the books the author wrote.</p>
<p>I take the list of books from the db, store them in <code>$the_books</code> array and try to create a checkbox and a label for every book using WPAlchemy loop :<br />
<code>while($metabox-&gt;have_fields('book', sizeof($the_books))): </code></p>
<p>Perhaps my thinking here is wrong, but how would you create something like this ?</p>
<p>When I check a book and update page, the value is saved fine and I can read it fine on the frontend, but I can&#8217;t make it display right in the admin. The problem I think is that when I create this inputs and labels, I use <code>$metabox-&gt;the_name()</code> but can&#8217;t use <code>$metabox-&gt;the_value()</code> because I have to display the name of the books from the array : <code>$the_books[$count_books]-&gt;name;</code>.</p>
<p>Hope you understood the problem and let me know if you think this is possible.<br />
Thank you.</p>
<p>Here is the full code I am using in the metabox template :</p>
<pre>
get_results('SELECT name FROM wp_wpsc_product_list WHERE active = 1 AND publish = 1');
?&gt;

have_fields('book', sizeof($the_books))): ?&gt;
	
    	&lt;input type=&quot;checkbox&quot; name=&quot;the_name(); ?&gt;" id="the_name(); ?&gt;" value="name; ?&gt;" get_the_value()) echo ' checked="checked"'; ?&gt; /&gt;
        &lt;label for=&quot;the_name(); ?&gt;"&gt;name; ?&gt; get_the_value()) echo 'value= '.$metabox-&gt;get_the_value(); ?&gt;

</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dimas		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-1481</link>

		<dc:creator><![CDATA[Dimas]]></dc:creator>
		<pubDate>Thu, 10 Jun 2010 15:32:52 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-1481</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-1479&quot;&gt;Derbois Nicolas&lt;/a&gt;.

@Derbois, I am glad you found your solution ... let me know what adjustments you made to solve your problem, this will definitely help me improve the code overall.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-1479">Derbois Nicolas</a>.</p>
<p>@Derbois, I am glad you found your solution &#8230; let me know what adjustments you made to solve your problem, this will definitely help me improve the code overall.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Derbois Nicolas		</title>
		<link>https://www.farinspace.com/wpalchemy-metabox-filtering-and-repeating-fields/#comment-1479</link>

		<dc:creator><![CDATA[Derbois Nicolas]]></dc:creator>
		<pubDate>Thu, 10 Jun 2010 14:11:20 +0000</pubDate>
		<guid isPermaLink="false">http://farinspace.com/?p=862#comment-1479</guid>

					<description><![CDATA[I have succeed to do my unlimited uploader (url return to the field from the wordpress media browser).

My code is a bit &quot;tricky&quot; but if I&#039;ll enhance.it, I will share it.

The problem was in the &quot;clone js script&quot; in your MetaBox class. Your original clone script duplicate form elements &quot;id&quot; thats why my other script(which return the url to the field couldn&#039;t work) (the duplicated field with the &quot;display:none&quot; field and with the class &quot; last tocopy&quot; haved the same Id as the field with the class &quot;last &quot;.]]></description>
			<content:encoded><![CDATA[<p>I have succeed to do my unlimited uploader (url return to the field from the wordpress media browser).</p>
<p>My code is a bit &#8220;tricky&#8221; but if I&#8217;ll enhance.it, I will share it.</p>
<p>The problem was in the &#8220;clone js script&#8221; in your MetaBox class. Your original clone script duplicate form elements &#8220;id&#8221; thats why my other script(which return the url to the field couldn&#8217;t work) (the duplicated field with the &#8220;display:none&#8221; field and with the class &#8221; last tocopy&#8221; haved the same Id as the field with the class &#8220;last &#8220;.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
