Forum Replies Created

Viewing 15 replies - 61 through 75 (of 96 total)
  • Hi,

    If the gallery drop down is empty, perhaps the code block code is wrong.
    First of all I can spot an error with the first part of the template code:

    [gallery]
    hideKey = true
    label = Select Gallery for this page. <br /> <a href=/wp-admin/admin.php?page=nggallery-manage-gallery>Click here</a> to modify the order of your gallery.
    type = select
    code = 0

    The other code block needs to go into the PHP Code Experimental Option section (not in the same template block). This code works for an older installation of NextGen 1.5

    global $wpdb;
    	$values = array();
    	$attachments = $wpdb->get_results('SELECT gid,title,path FROM wp_ngg_gallery');
    	foreach ($attachments as $attachment) {
    	$str = '[ngggallery id=' . $attachment->gid . ']';
     $values[] = $str;
    }

    Does that work?

    Hi there,

    I have done something similar with NextGen and the CFT.

    I used a select drop down that grabs the NextGen Gallery data. This code is from a previous project I worked on, I’ll share it with you:

    Template:

    [gallery]
    hideKey = true
    label = Select Gallery for this page. <br /> <a href=/wp-admin/admin.php?page=nggallery-manage-gallery>Click here</a> to modify the order of your gallery.
    type = select
    code = 0'

    Code Block 0

    global $wpdb;
    	$values = array();
    	$attachments = $wpdb->get_results('SELECT gid,title,path FROM wp_ngg_gallery');
    	foreach ($attachments as $attachment) {
    	$str = '[' . $attachment->gid . ']----->'.$attachment->title .'<-----!!' .$attachment->path . '!!';
    	$values[] = $str;
    	 }

    That will make a drop down containing the gallery id [id] the name of the gallery and the !!path!! to the gallery folder. I put them in delimeters so as to be able to extract them in the template. I think I needed both !!path!! and [id] to get it working. You can adjust the $str to how you want it displayed to your editor.

    You may just want to have the shortcode [nggallery id=x] being used in the field. That edit will be easy to make:

    $str = '[ngggallery id=' . $attachment->gid . ']';

    In you template you will just have to apply filters on that custom field that you’ve made so it outputs the gallery.

    In your template:

    <?php
    $unprocessedfield = get_post_meta($post->ID, 'nameofyourcustomfield',true);
    $processedfield = apply_filters('the_content', $unprocessedfield );
    echo $processedfield;
    ?>

    That should get you moving in the right direction.

    You’re welcome.
    Please mark the topic closed too thanks.
    Enjoy your day!

    ok seriously:
    <?= wp_get_attachment_link("document_1") ?> should be <?= wp_get_attachment_link($document_1) ?>
    You need to pass a variable not a string.

    Thread Starter proximity2008

    (@proximity2008)

    Seems to be a clash with another plugin. Ok now.

    I would create a text field and add a css class to it to hide it – thus you have a “hidden field”.

    I had a little after thought.
    You will need to add a check to see if the page has been loaded before, otherwise the it will recheck the default_checked checkboxes, over-riding them if the user wants them really unchecked.

    Add a test to see if another field has been entered.

    [anotherfield]
    type = text
    label = A normal cft field in your template
    class = field_test
    
    [test]
    type= checkbox
    value = apple # orange # banana
    default = orange
    valueLabel = apples # oranges # bananas
    label = text
    class=default_checked

    Update text description area:

    <script type="text/javascript">
    jQuery(document).ready(function () {
    	if( jQuery('.field_test').val() == ''  ) {
    	jQuery('.default_checked').attr('checked', true);
    	}
    });
    </script>

    Here’s a workaround.

    In your template description add this:

    <script type="text/javascript">
    jQuery(document).ready(function () {
    	jQuery('.default_checked').attr('checked', true);
    });
    </script>

    Remember you can any script into your template description field. I use it to attach css and js on a per template basis.

    The following code block creates a CFT template with 3 checkboxes that will all be checked when the page loads:

    [test]
    type= checkbox
    value = apple # orange # banana
    default = orange
    valueLabel = apples # oranges # bananas
    label = text
    class=default_checked

    You could make individual checkboxes with that default_checked class applied. That will ensure that when that the only checkboxes you want are checked.

    Have a nice day.

    Hi Inforcality,

    At the moment I am doing something incredibly similar ??
    Here is what I came up with:

    MY CFT CODE:

    [project]
    type = fieldset_open
    multiple = true
    multipleButton = true
    
    [project_name]
    type = textfield
    size = 35
    label = Project Name
    class = project_name
    blank = true
    
    [project_image]
    type=file
    relation=true
    label = upload image
    class = project_image
    blank = true
    
    [project_type]
    type=select
    value = WordPress # Joomla!  # Static
    class = project_type
    blank = true
    
    [project_description]
    type=textarea
    rows=10
    cols = 30
    label = Description of Project
    class = project_description
    blank = true
    
    [project_link]
    label = Link to project
    type = text
    size = 35
    class = project_link
    blank = true
    
    [project]
    type = fieldset_close

    So that will give you a rather jumbled data in the database.
    The trick is the naming of the fields (you’ve got that sorted I see), I’ve used “project”. That will make it easier to retrieve and sort the data.

    In your template:

    // retrieve entries with project prefix
    				$sql = " SELECT * FROM $wpdb->postmeta	WHERE post_id = $post->ID AND meta_key LIKE '%project%' ORDER BY <code>meta_id</code> ASC";
    				$data_objects = $wpdb->get_results($sql);
    				$project = array();
    				$i = 0;
    
    				foreach($data_objects as $data) {
    
    					// the name of the fieldset:
    					if($data->meta_key == 'project') {
    						$limit = $data->meta_value;
    					}
    
    					$i = ( $i <= $limit ) ? $i : 1;
    
    					if( $data->meta_value != $limit ) {
    					$project[$i]["$data->meta_key"] = $data->meta_value;
    					}
    					$i++;
    				}
    				//check data
    				//print_r($project);
    
    				foreach( $project as $key){
    					// you will need to check if the value is blank but you get the idea.
    					echo 'Project Name: ' . $key['project_name'] .'<br />';
    					echo 'Project Image: ' . $key['project_image'] .'<br />';
    					echo 'Project Type: '.  $key['project_description'] .'<br />';
    					// etc....
    				}

    I’m not the greatest programmer in the world but that should do it. It is untested at the moment and there are no data checks. But you get the idea.

    Hi riasaurusrex,

    I’ve done somthing similar. I’ve used comma seperated image ids and just used a text field. From the Front end, the template file just explodes the inputted data and the caption data, alt text is pulled from the post-attachment.

    I would reach for the NextGen Gallery plugin for this kind of thing. I am not sure how you’d go with pagination with the CFT alone. The NextGen Gallery plugin is one of the best.

    Hi Draymondkc,

    I would look into the Advanced Custom Field Widget

    I too have had this issue.

    In the end I appended a number to the end of each similar field like so:

    [tour_day_1]
    type = text
    size = 45
    label = Tour Day Title
    
    [tour_day_2]
    type = text
    size = 45
    label = Tour Day Title
    
    [tour_day_3]
    type = text
    size = 45
    label = Tour Day Title

    In the template file I setup a while loop to output these fields:

    $i=1;
    while( get_post_meta($post->ID, "tour_day_{$i}", true) !='' ){
    ...
     echo get_post_meta($post->ID, "tour_day_{$i}", true);
    ...
    $i++;
    }

    This of course assumes that every custom for tour_day is filled out otherwise the loop stops.

    Would be interesting to see if anyone else has had this issue too!

    Tawqee3 that should work.

    Do a print_r on $post and see if it has the correct id for the function.

    Just before you call the get_post_meta function:

    print_r($post);

    Is the post id the one you are expecting for the get_post_meta function to pull the custom field?

Viewing 15 replies - 61 through 75 (of 96 total)