Skip Navigation

[Résolu] Building a small part by using Views design on existing website

This support ticket is created Il y a 7 années et 11 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 réponses, has 2 voix.

Last updated by kelvinL-2 Il y a 7 années et 11 mois.

Assigned support staff: Luo Yang.

Auteur
Publications
#269627
view_block.jpg

Dear Sir/Madam,

I did purchase the Toolset. I plan to instal the plugins and use the UI to design a small part and plug into my existing website template. As the website is customised for a long time and I could not start everything from zero using Toolset. Could you please advise me which plugins I should use to complete my goal.

Please refer to the attachment, I only want to make a simple post view with the title, featured image, and some custom field data, and then extract the php code and put it into my existing layout. Should I use the view to make the output first and then put the php code, how can I know the code?

I look into the document https://toolset.com/documentation/views-php-integration/ and I totally no idea how can I know the $args, is there any example for my reference?

If Views is not the suggested solution, which plugins should I use. Hope you can guide me a bit of step.

Best regards,

Kelvin.

#269632

Below please find the code I currently works for the above jobs, but I still need the help in using the plugins because I need to do similar job at other pages with more complicated query.

// 8. Recent Posts
$args = array('posts_per_page' => 1, 'post_type' => 'post', 'category' => 'new-arrival');

$the_posts = get_posts($args);

echo "<div id='WeekCarPromo' class='col-md-6 margin-left-none padding-left-none'>";
echo "<div class='heading_bar'><img src='/images/heading_week_promo.png'></div>";

if(!empty($the_posts)){
foreach($the_posts as $single){

$return .= "<div class=\"thumb-image\">";
$return .= "<a href='" . get_permalink($single->ID) . "'><h4>" . $single->post_title . "</h4></a>";

if(has_post_thumbnail($single->ID)){
$return .= get_the_post_thumbnail( $single->ID, 'full', array('class' => 'recent_thumbnail') );
}

$return .= "</div>";
$return .= "<div class='car_details'>";
$return .= "<div class='post-row'>";
$return .= "<div class='post-col-2'>" . types_render_field("model", array("output"=>"raw", "post_id" => $single->ID)) . "</div>";
setlocale(LC_MONETARY, 'en_HK');
$fmt = "%i";
$return .= "<div class='post-col-2'>" . money_format($fmt, types_render_field("price", array("output"=>"raw", "post_id" => $single->ID))) . "</div>";
$return .= "</div>";
$return .= "</div>";
$return .= "<div class='car_details'>";
$return .= "<div class='post-row'>";
$return .= "<div class='post-col-3'>" . types_render_field("year", array("output"=>"raw", "post_id" => $single->ID)) . "</div>";
$return .= "<div class='post-col-3'>" . types_render_field("capacity", array("output"=>"raw",'show_name'=>'true', 'post_id' => $single->ID)) . "cc" . "</div>";
// $return .= "<div class='post-col-3'>" . types_render_field("capacity", array("output"=>"raw",'show_name'=>'true', 'post_id' => $single->ID)) . "cc" . "</div>";
$return .= "<div class='post-col-3'>" . types_render_field("mode", array("output"=>"html", 'show_name'=>'true', 'post_id'=> $single->ID)) . "</div>";
$return .= "</div>";
$return .= "<div class='post-row'>";
// $return .= "<div class='post-col-1'>" . types_render_field("brief", array("output"=>"html", 'post_id'=> $single->ID)) . "</div>";
$return .= "</div>";
$return .= "</div>";
$return .= "<div class=\"clearfix\"></div>";

echo $return;
}
}

#269649

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

In your case, you can try Views plugin, to create a view filter with your another thread:
https://toolset.com/forums/topic/new-user-want-to-have-custom-view-sample/

For Views function render_view($args);
For example, you have create a view with title "my view name", then you will be able output it with php code:
<?php echo(render_view(array('name'=> 'my view name'))); ?>

And I suggest you start with our document of Views:
https://toolset.com/documentation/user-guides/
click "Views Plugin"

#270397

Noted with thanks!