Change Listing Base Template from default

It looks like when a listing is created in Directory, it will automatically use the theme default template as the basis for the page layout, then the single-listing.php to lay out the content. But is there a way to change the base template from the default, to say, a full-width, no sidebar template?

  • Anang

    Hi David

    Thanks for contacting us :slight_smile:

    If you want to create your own directory template, you can override the default template :slight_smile:
    All you have to do is copy the files from plugins/directory/ui-front/general to your theme (or child theme if that's what you're using).
    So if you want to change single page layout, you need to copy single-listing.php from plugins/directory/ui-front/general to your themes folder and modified it.

    Let me know if you need anything else :slight_smile:

    Best Regards

  • David

    No, I understand that part, but modifying single-listing.php doesn't change the fact that the overall structure of the listing page is still based on the theme default template. The content area is the only thing that is modifiable in single-listing.php. I want to be able to remove the sidebar. There is no call to the sidebar in single-listing.php, but the sidebar still shows up because it is using the theme's single.php to lay out the page. How do I make it instead use a different theme template - specifically, full_width.php? I can change the template of the Listings page, but not an individual Listing page.

  • David

    That was a useful post, thank you. I now have a customized listing page, that has almost everything I want on it. If I use the default single-listing.php there is a nice little contact form that shows up, but I can't figure out how to get that to work on a custom page. Simply copying the code from the original template does not work. The php just breaks the page. Is there any way I can get that form to show up on a custom template?

  • David

    Here is the code, not sure how well this will format, but I'll give it a try. I don't get any actual errors. The page just doesn't render anything from the form tag on down. I presume it is all that php code like <?php _e('Contact User', $this->text_domain ); ?> which I assume is meaningless without some sort of helper file?

     * @package WordPress
     * @subpackage Default_Theme
     Template Name: Single Listing
    get_header(); ?>
    <script type="text/javascript" src="/wp-content/plugins/directory/ui-front/js/ui-front.js" >
    <!-- begin leftwrap -->
    <div id="left-wrap" class="dir_list" style="width:100%">
        <!-- begin text block -->
        <div class="sub about" style="width:100%">
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div style="padding-top:0;" class="post" id="post-<?php the_ID(); ?>">
    			<div class="entry">
                <div id="listingHeader">
    	            <?php if(has_post_thumbnail() ) the_post_thumbnail( array( 275, 100 ), array( 'class' => 'alignleft' ) ); ?>
         <div id="listingTitle">
             <h1><?php the_title(); ?></h1>
             <p><a target="_blank" href="<?php echo do_shortcode('[ct id="_ct_text_5558b7a5ca00f" property="title | description | value"]'); ?>"><?php echo do_shortcode('[ct id="_ct_text_5558b7a5ca00f" property="title | description | value"]'); ?></a> | <?php echo do_shortcode('[ct id="_ct_text_5559ec07e950b" property="title | description | value"]'); ?></p>
             <?php do_action('sr_avg_rating'); ?>
            <!--contact form -->
                    <form method="post" action="#" class="contact-user-btn action-form" id="action-form">
    	<input type="submit" name="contact_user" value="<?php _e('Contact User', $this->text_domain ); ?>" onclick="dr_listings.toggle_contact_form(); return false;" />
    <div class="clear"></div>
    <form method="post" action="#" class="standard-form base dr-contact-form" id="confirm-form">
    	global $current_user;
    	$name   = ( isset( $current_user->display_name ) && '' != $current_user->display_name ) ? $current_user->display_name :
    	( ( isset( $current_user->first_name ) && '' != $current_user->first_name ) ? $current_user->first_name : '' );
    	$email  = ( isset( $current_user->user_email ) && '' != $current_user->user_email ) ? $current_user->user_email : '';
    	<div class="editfield">
    		<label for="name"><?php _e( 'Name', $this->text_domain ); ?> (<?php _e( 'required', $this->text_domain ); ?>)</label>
    		<input type="text" id="name" name ="name" value="<?php echo ( isset( $_POST['name'] ) ) ? $_POST['name'] : $name; ?>" />
    		<p class="description"><?php _e( 'Enter your full name here.', $this->text_domain ); ?></p>
    	<div class="editfield">
    		<label for="email"><?php _e( 'Email', $this->text_domain ); ?> (<?php _e( 'required', $this->text_domain ); ?>)</label>
    		<input type="text" id="email" name ="email" value="<?php echo ( isset( $_POST['email'] ) ) ? $_POST['email'] : $email; ?>" />
    		<p class="description"><?php _e( 'Enter a valid email address here.', $this->text_domain ); ?></p>
    	<div class="editfield">
    		<label for="subject"><?php _e( 'Subject', $this->text_domain ); ?> (<?php _e( 'required', $this->text_domain ); ?>)</label>
    		<input type="text" id="subject" name ="subject" value="<?php echo ( isset( $_POST['subject'] ) ) ? $_POST['subject'] : ''; ?>" />
    		<p class="description"><?php _e( 'Enter the subject of your enquiry here.', $this->text_domain ); ?></p>
    	<div class="editfield">
    		<label for="message"><?php _e( 'Message', $this->text_domain ); ?> (<?php _e( 'required', $this->text_domain ); ?>)</label>
    		<textarea id="message" name="message"><?php echo ( isset( $_POST['message'] ) ) ? $_POST['message'] : ''; ?></textarea>
    		<p class="description"><?php _e( 'Enter the content of your enquiry here.', $this->text_domain ); ?></p>
    	<div class="editfield">
    		<label for="dr_random_value"><?php _e( 'Security image', $this->text_domain ); ?> (<?php _e( 'required', $this->text_domain ); ?>)</label>
    			<img class="captcha" src="<?php echo admin_url('admin-ajax.php?action=dr-captcha');?>" />
    		<input type="text" id="dr_random_value" name ="dr_random_value" value="" size="8" />
    		<p class="description"><?php _e( 'Enter the characters from the image.', $this->text_domain ); ?></p>
    	<div class="submit">
    			<?php wp_nonce_field( 'send_message' ); ?>
    			<input type="submit" class="button confirm" value="<?php _e( 'Send', $this->text_domain ); ?>" name="contact_form_send" />
    			<input type="submit" class="button cancel"  value="<?php _e( 'Cancel', $this->text_domain ); ?>" onclick="dr_listings.cancel_contact_form(); return false;" />
            <!--end contact form-->
    				<div style="clear: both;">
    				<?php the_content('<p class="serif">' . __('Read the rest of this page &raquo;', 'kubrick') . '</p>'); ?>
    				<div class="videoWrapper">
    					<?php echo do_shortcode('[ct id="_ct_text_5558b86d8c2c2" property="title | description | value"]'); ?>
    				<?php	// If comments are open or we have at least one comment, load up the comment template.
    					if ( comments_open() || get_comments_number() ) {
    					} ?>
    				<?php wp_link_pages(array('before' => '<p><strong>' . __('Pages:', 'kubrick') . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    		<?php endwhile; endif; ?>
    	<!-- finish text block -->
    <!-- finish leftwrap -->
    <?php get_footer(); ?>
  • Anang

    Hi David

    Do you use multi language on your site ? If not you can just replace this line :
    <?php _e('Contact User', $this->text_domain ); ?>
    Contact User
    That line is used for translation, and it's worked if you only print the first parameter string. $this on that code is reference to Main Class of Directory plugins. So it's not found when we use it on custom template. And you need to include some lines to display form sent status :

    <?php if ( isset( $_POST['_wpnonce'] ) ): ?>
    <br clear="all" />
    <div id="dr-message-error">
    	<?php _e( "Send message failed: you didn't fill all required fields correctly in contact form!", $this->text_domain ); ?>
    <br clear="all" />
    <?php endif; ?>
    <?php if ( isset( $_GET['sent'] ) ):
    if(1 == $_GET['sent'] ): ?>
    <br clear="all" />
    <div id="dr-message">
    	<?php _e( 'Message is sent!', $this->text_domain ); ?>
    <br clear="all" />
    <?php else: ?>
    <div id="dr-message-error">
    	<?php _e( 'Email service is not responding!', $this->text_domain ); ?>
    endif; ?>

    And don't forget to replate $this->text_domain too :slight_smile:

    Let me know if you have any questions :slight_smile:

    Best Regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.