How is MF2 Front End code different?

128 views
Skip to first unread message

Reaxion

unread,
Mar 16, 2013, 1:14:47 PM3/16/13
to magic-...@googlegroups.com
Hi!

So far I've been a hardcore MF1 user, so that's probably why I'm having such trouble working with MF2 - I can't even get a line of text to display from a field.

I'm trying to display a duplicate group, and below are 2 chunks of code that would work with MF1 but not MF2 (because I'm obviously missing something)



--------------------
This is how I would usually display a duplicate group from a POST
--------------------
           
<?php $my_query = new WP_Query('category_name=slider'); ?>

<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>

<ul>
                     
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
           
             <?php $Slides= getGroupOrder('slider_title');
              foreach($Slides as $Slide){
              $new_params = array("w" => 375,"h" => 325, "zc" => c);
             ?>

                 <li>
                     <?php echo get('slider_title', $Slide,1,1,NULL,$new_params); ?>
                 </li>
    <?php } ?>  
    </ul>
    <?php endwhile; ?>  


--------------------
This is how I would usually display the same duplicate group from a PAGE
--------------------

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

<ul>
     <?php $Slides= getGroupOrder('slides_title');
              foreach($Slides as $Slide){
              $new_params = array("w" => 375,"h" => 325, "zc" => c);
           ?>
          
           </li>
           <?php echo get_image('slides_image', $Slide,1,1,NULL,$new_params); ?>
           <?php echo get('slideshow_title',$Slide); ?>
          
                   </li>
       <?php } ?>  
    </ul>
    <?php endwhile; ?>


But generally all I get is:
 Fatal error: Call to undefined function getGroupOrder() in /home/twoandten/www/www/wp-content/themes/starkers/home.php on line 24

Which in this case line 24 is : <?php $Slides= getGroupOrder('slides_title');


If it means anything, the "Post Type" is home_page, and you got it, I'm trying to display this on my homepage slider.



When I use the get_group or get_order_group here http://wiki.magicfields.org/doku.php?id=working_with_groups_duplicated_groups_and_duplicated_fields_v20 I don't get an error, I just get nothing.

Any pointers would be great!
Scott

Jason B

unread,
Mar 16, 2013, 7:42:11 PM3/16/13
to magic-...@googlegroups.com
In reference to the error, getGroupOrder() doesn't exist as a function in the mf_front_end.php file.  As for the other part, are you sure 'slider_title' is a group name and not a field name?

Reaxion

unread,
Mar 16, 2013, 10:14:53 PM3/16/13
to magic-...@googlegroups.com
That's right, slider_title is a field, but in MF1 using any field from a group you want to work with is a way to define what group you want to display - if that doesn't make sense, check out the mf1 wiki.

So, even ignore any of my code, what would the code for displaying a duplicate group using MF2 look? I'm sure I found it in the mf2 documentation, but as usual there is usually something missing. I wonder if it has anything to do with the post type being "home_page" instead of Post? I'm grabbing at straws here...

Thx!

Jason B

unread,
Mar 16, 2013, 10:40:00 PM3/16/13
to magic-...@googlegroups.com
You'll need the group name and I don't use the get_order_group() for anything but I do use get_group() for some things.  Here's something I use for a set of photos attached to a custom post type.  

<?php $other_photos  = get_group('other_images');?>  //Gets the group into a variable
<div class="">
<?php
//$size="h=450&w=450&zc=1&q=100"; This was commented out because I'm actually loading the full size images for a lightbox load in.
$i = 1; //This initializes the counter.  Group order could be useful to replace this but I was having some issues with get_group_order as well and scrapped the idea of using get_group_order()
foreach ( $other_photos  as  $other_photo ) {
echo '<img src="'.get_image('other_images_image', $i, 1, 0, Null, $size).'" class="lightbox_trigger" width="250" height="250" alt="'. get('other_images_description',$i).'"/>';
$i++;
}
$i = 1; //resets the counter in case I need it for something else.
?>

Reaxion

unread,
Mar 18, 2013, 1:59:50 PM3/18/13
to magic-...@googlegroups.com
Unfortunately I'm still getting nothing. There are so many more options in MF2 that I don't know what could be fouling things up.

Some new things that are set are:
  • The post type (which makes a new tab in the admin) is called Home Page or "home_page".
  • In the options for the post type I have the capability set for "page" (I've tried post as well).
  • The duplicate group I'm working with is titled "Slides".
  • I am trying to get the group to show up on my home.php page template.
Here is the code with the loop that I would EXPECT to work based on yours, but doesn't, which I'm sure is my fault no doubt:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

<?php $other_photos  = get_group('Slides');?>  //Gets the group into a variable

<div class="">
        <?php
        //$size="h=450&w=450&zc=1&q=100"; This was commented out because I'm actually loading the full size images for a lightbox load in.
        $i = 1; //This initializes the counter.  Group order could be useful to replace this but I was having some issues with get_group_order as well and scrapped the idea of using get_group_order()
        foreach ( $other_photos  as  $other_photo ) {
            echo '<img src="'.get_image('slides_image', $i, 1, 0, Null, $size).'" class="lightbox_trigger" width="250" height="250" alt="'. get('slides_title',$i).'"/>';

            $i++;
    }
        $i = 1; //resets the counter in case I need it for something else.
?>

<?php endwhile; ?>


If you post any code, please include the whole loop. I'm really a master at MF1 but this just makes me waste bang my head against the wall :) I just need at least one snippet of code to crack open MF2 so I can run with! With MF1 I would've been done in about 15 minutes, but I feel I should upgrade!

Thanks!

Reply all
Reply to author
Forward
0 new messages