Multiple Templates
-
HI,
i was wondering if we are able to have multiple templates for the PDF generator.
for example… i have set a template up, for one of our custom_post_types.. and have has to extensively add custom field information to the dkpdf-index.php file – so that it will display all the information that we are needing to be generated.. and this is worked great..
but we have 5 different custom_posts_types and they all pull in different Custom Fields information… so is is possible to have multiple templates..?
eg..dkpdf-index.php – default
dkpdf-shorttermfixed.php – with code that’s specific to short term fixed post_type
dkpdf-shorttermflexible.php – with code that’s specific to short term flexible post_typemy dkpdf-index.php (in theme directory)
<?php
/**
* dkpdf-index.php
* This template is used to display the content in the PDF
*/
?><html>
<head><link type="text/css" rel="stylesheet" href="<?php echo get_bloginfo( 'stylesheet_url' ); ?>" media="all" />
<?php
$wp_head = get_option( 'dkpdf_print_wp_head', '' );if( $wp_head == 'on' ) {
wp_head();
}
?><style type="text/css">
body {
background:#FFF;
font-size: 100%;
}<?php
// get pdf custom css option
$css = get_option( 'dkpdf_pdf_custom_css', '' );
echo $css;
?></style>
</head>
<body>
<?php
global $post;
$pdf = get_query_var( 'pdf' );
$post_type = get_post_type( $pdf );// if is attachment
if( $post_type == 'attachment') { ?><div style="width:100%;float:left;">
<?php
// image
$arr_sliderimages = get_gallery_images();
if (count($arr_sliderimages) > 0) {
$count = 1;
foreach ($arr_sliderimages as $image) {
$resized = aq_resize($image, 700, 450,true);
?>
">
<img alt="" src="<?php echo $resized ?>" />
<?php $count = $count + 1;
}
}
if (count($arr_sliderimages) > 1) {
$count = 1;
foreach ($arr_sliderimages as $image) {
$resized = aq_resize($image, 700, 450,true);
?>
<img alt="" src="<?php echo $resized ?>" />
<?php $count = $count + 1;
}
}
?><?php
// caption, description
$thumb_img = get_post( get_post_thumbnail_id() );if( $thumb_img ) {
echo '<p style="margin-top:30px;">Caption: ' . $thumb_img->post_excerpt .'</p>';
echo '<p>Description: ' . $thumb_img->post_content .'</p>';}
?>
<?php
// metadata
$metadata = wp_get_attachment_metadata( $post->ID );if( $metadata ) {
$metadata_width = $metadata['width'];
$metadata_height = $metadata['height'];
$image_meta = $metadata['image_meta'];echo '<p style="margin-top:30px;">Dimensions: '. $metadata_width .' x '. $metadata_height .'</p>';
// image metadata
foreach ($image_meta as $key => $value) {echo $key. ': '. $value .'
';}
}
?>
</div>
<?php
} else {
$args = array(
'p' => $pdf,
'post_type' => $post_type,
'post_status' => 'publish'
);$the_query = new WP_Query( apply_filters( 'dkpdf_query_args', $args ) );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
global $post;
?><div class="dkpdf-content">
<?php
// Set the image for the pdf
$arr_sliderimages = get_gallery_images();
if (count($arr_sliderimages) > 0) {
$count = 1;
foreach ($arr_sliderimages as $image) {
$resized = aq_resize($image, 700, 450,true);
?>
">
<img alt="" src="<?php echo $resized ?>" />
<?php $count = $count + 1;
}
}
if (count($arr_sliderimages) > 1) {
$count = 1;
foreach ($arr_sliderimages as $image) {
$resized = aq_resize($image, 700, 450,true);
?>
<img alt="" src="<?php echo $resized ?>" />
<?php $count = $count + 1;
}
}
?>
<?php // create the following content for the pdf ?>
<div class="post-content">
<h6 style="text-align:center"><span style="color:#1a1a1a">Specification: </span><?php echo get_post_meta(get_the_ID(), 'Specification', true);?></h6><div style="width:100%; max-width:400px; margin:0px auto; text-align:center">
<h5>2 Year Contract</h5>
<p>Payment Profile: <span style="color:#45749A;"><?php echo get_post_meta($post->ID, '2 Year Payment Profile', true); ?></span></p>
<p>Initial Payment: <span style="color:#45749A;">£<?php echo get_post_meta(get_the_ID(), 'Initial Payment 2y', true); ?> +VAT</span></p>
<p>Followed by <span style="color:#45749A;"><?php echo get_post_meta(get_the_ID(), '2 Year Monthly Payments', true); ?></span> monthly payments: <span style="color:#45749A;">£<?php echo get_post_meta(get_the_ID(), '2 Year 10k plus VAT', true); ?> + VAT</span></p>
<p>Total Allowed Mileage: <?php echo get_post_meta($post->ID, '2 Year Mileage', true); ?></p>
<h5>3 Year Contract</h5>
<p>Payment Profile: <span style="color:#45749A;"><?php echo get_post_meta($post->ID, '3 Year Payment Profile', true); ?></span></p>
<p>Initial Payment: <span style="color:#45749A;">£<?php echo get_post_meta(get_the_ID(), 'Initial Payment 3y', true); ?> +VAT</span></p>
<p>Followed by <span style="color:#45749A;"><?php echo get_post_meta(get_the_ID(), '3 Year Monthly Payments', true); ?></span> monthly payments: <span style="color:#45749A;">£<?php echo get_post_meta(get_the_ID(), '3 Year 10k plus VAT', true); ?> + VAT</span></p>
<p>Total Allowed Mileage: <?php echo get_post_meta($post->ID, '3 Year Mileage', true); ?></p>
<h5>4 Year Contract</h5>
<p>Payment Profile: <span style="color:#45749A;"><?php echo get_post_meta($post->ID, '4 Year Payment Profile', true); ?></span></p>
<p>Initial Payment: <span style="color:#45749A;">£<?php echo get_post_meta(get_the_ID(), 'Initial Payment 4y', true); ?> +VAT</span></p>
<p>Followed by <span style="color:#45749A;"><?php echo get_post_meta(get_the_ID(), '4 Year Monthly Payments', true); ?></span> monthly payments: <span style="color:#45749A;">£<?php echo get_post_meta(get_the_ID(), '4 Year 10k plus VAT', true); ?> + VAT</span></p>
<p>Total Allowed Mileage: <?php echo get_post_meta($post->ID, '4 Year Mileage', true); ?></p>
<p> </p>
<p>If you wish to be quoted on higher mileage, or longer contract, please call us on 0330 330 9425</p>
</div>
<p> </p>
<h3 class="bar">Vehicle Details</h3>
<div id="vehicle-description">
<ul class="list_left" style="width:100%; max-width: 320px; float:left; ">- Make: <?php echo get_post_meta(get_the_ID(), 'Make', true); ?>
- Model: <?php echo get_post_meta(get_the_ID(), 'Model', true); ?>
- Derivative: <?php echo get_post_meta(get_the_ID(), 'Derivative', true); ?>
- Vehicle Type: <?php echo get_post_meta(get_the_ID(), 'Vehicle Type', true); ?>
- Transmission: <?php echo get_post_meta(get_the_ID(), 'Transmission', true); ?>
- Fuel Type: <?php echo get_post_meta(get_the_ID(), 'Fuel Type', true); ?>
- Stock Levels: <?php echo get_post_meta(get_the_ID(), 'Stock Levels', true); ?>
- CO<sub>2</sub> Emissions: <?php echo get_post_meta(get_the_ID(), 'Co2 Emissions', true); ?> g/km
- MPG (Combined): <?php echo get_post_meta(get_the_ID(), 'MPG Urban', true); ?> mpg
- Tyres: <?php echo get_post_meta(get_the_ID(), 'Tyres', true); ?>
- Maintenance: <?php echo get_post_meta(get_the_ID(), 'Maintenance', true); ?>
- Excess Mileage: <span style="color:#45749A;">£<?php echo get_post_meta(get_the_ID(), 'excess_value', true); ?> +VAT </span>per mile.
- Delivery Charge: FOC in England & Wales
- Lead Time: <?php echo get_post_meta(get_the_ID(), 'Delivery', true); ?>
<ul class="list_right" style="float:left; margin-bottom:40px;">
<div style="clear:both"></div>
</div>
<div id="single-listing" style="width:100%; margin-top:20px;">
<h3 class="bar"><span><span>Specification</span></span></h3>
<p></p>
<?php $manufacturer = ucwords(strtolower(get_post_meta($post->ID, 'Make', true))); ?>
<p>Please visit <?php echo $manufacturer; ?>'s website for a specification of the chosen model. The models do change on a monthly basis so please do confirm this with your sales person at the time of ordering. Short Term Leasing Ltd cannot be held responsible for any manufacturer changes.</p>
<?php if(get_post_meta($post->ID, 'Make', true) != '') { ?>
<h5>Manufacturer's link</h5>
<p>Please ">click here to visit the <?php echo $manufacturer; ?>'s website.</p>
<?php } else { } ?>
<h3 class="bar"><span><span>Contract Information</span></span></h3>
<p></p>
<?php echo get_post_meta(get_the_ID(), 'Contract Blurb', true); ?>
<p>Figures correct at time of publishing of <?php echo get_the_modified_date() ;?>. + E&OE. </p>
<p>Quote Reference: <?php echo html_entity_decode(get_post_meta(get_the_ID(), 'Supplier', true)); ?></p>
<h3 class="bar"><span><span>Price Comparison</span></span></h3>
<p></p>
<p>Short Term Leasing Ltd offer competitive fixed and flexible vehicles with hundreds to choose from. Whist we try and remain competitive our deals change on a daily basis should you get a cheaper quote from another short term vehicle provider plase send over the official quotation and we will do our best to match the offer.</p>
<p>We also offer conventional contract hire and leasing on 24/36/48 month contracts and have over 12 different funders to get quotations from, all of which have different levels of support, discount and calculation of residual value of the vehicle at the end of the term. We may sometimes be more expensive than quotes you have received from other contract hire and leasing brokers or even dealers, but we will do what we can to get the same price.</p>
<p>If we are more expensive, please do not hesitate to send over your official quotation, we will then pass this onto the funders to see if there is anything else we can do. If we can't we will be upfront and tell you, but we are always willing to try.</p>
<p>Should a price not display on the page, the price may not have come across from our funders or we are not allowed to advertise the price, but don't give up on us, give us a call on 0330 330 9425 or send us an email with your vehicle requirements and let our team do the hard work for you</p>
<p></p><h3 class="bar"><span><span>Vehicle Details Explained</span></span></h3>
<p></p>
<p>Derivitative: Manufacturers create so many different models of their vehicles, from the very basic to the fully kitted out models that include just about everything. The specification can change on a monthly basis of these models, which can make this website difficult to keep up to date and the models that we have on order may differ from those advertised on the manufacturers website.</p>
<p>Body Type: There are various different body types, we generally have a set list we use to describe these vehicles; Hatchback, Estate, Saloon, 4x4, LCV, Coupe, Cabriolet/Convertible, although a few more may slip through from time to time. If in doubt call the Cocoon Vehicles team.</p>
<p>Transmission: Generally we only publish two types of transmission on our website, which is Automatic and Manual, although their are various different types of automatic transmission such as TipTronic, CVT and DSG, its easier to keep to what everybody understands.</p>
<p>Fuel Type: In recent years, just Petrol, Diesel and LPG were available, now we have electric cars and hydrogen fuel cell vehicles coming into the mix. At the moment if the vehicle is a Hybrid we will just state HYBRID in the fuel type, we may however change this in the future.</p>
<p>AdBlue: Adblue is used in many modern vehicles to reduce NOx from your Diesel Car or Van. AdBlue is very easy to use and is classed as a harmless substance, generally you top AdBlue up in a dedicated tank. Please note that AdBlue is classed as consumable.</p>
<p>Diesel Particulate Filter (DPF): DPF's have been fitted to most diesel vehicles to help meet strict European Emmissions standards, for them to work efficiently the vehicle needs to drive at a steady speed for at least 15-20 mins, to allow the filter to heat up enough to regenerate.</p>
<div style="clear:both"></div>
</div>
</div>
</div><?php }
} else {
echo 'no results';
}wp_reset_postdata();
}
?>
</body>
</html>
The topic ‘Multiple Templates’ is closed to new replies.