Not enough info to answer, really. Can you provide more details? Do you have any code to share?
How can i get multiple dynamic products in dynamic pages on laravel
I am using laravel query builder not eloquent
i am using shortcodes for products fetching process, but issue is that only single product worked fine, if i have more than one rows then page design fetched 2 times and i want to irate only sub div instead of full design, and i put the code here but msg length is too short.
Show us the code where you iterate products loop.
here is my controller code
function index(Request $request, $slug){
//Query For Getting Pages
$query = DB::table('tbl_pages')
->select('*')
->where('slug', $slug)
->where('status', 0);
$content = $query->first();
//check either page is exist or not
if(!empty($content)){
//check either page have shortcode or not
$short_code_0 = strpos($content->content, '{type == 0}');
//if short code exist
if(!empty($short_code_0)){
$content = ShortCodes::sale_products($content);
}
//Page Data
$result = array(
'page_title' => $content->title,
'meta_keywords' => $content->meta_keywords,
'meta_description' => $content->meta_description,
'content' => $content->content,
);
//call page
return view('site.pages.index', $result);
}else{
print_r("<center><h4>Error 404 !!<br> The page you're looking for is not available<br> Please move back<h4></center>");
}
}
here is my helper code
//here i am using Query For Getting Products
//make html codes
if(!empty($result)){
//shortcodes
$shortcodes[] = [
'{id}','{p_name}','{p_slug}','{b_name}','{b_slug}','{img_src}','{sale_price}','{regural_price}','{sale_tag}','{featured_tag}','{rating}','{type == 0}',
];
foreach($result as $row){
if($row->featured_product == 0){
$featured = '<span class="tg-themetag" style="margin-left: 15px;">Featured</span>';
}else{
$featured = '';
}
//shortcodes_data
$shortcodes_data[] = [
'{id}' => $row->p_id,
'{p_name}' => $row->p_name,
'{p_slug}' => $row->p_slug,
'{b_name}' => $row->b_name,
'{b_slug}' => $row->b_slug,
'{img_src}' => URL('public/assets/user/images/ecommerce/products/'.$row->featured_image),
'{sale_price}' => $row->sale_price,
'{regural_price}' => $row->regural_price,
'{sale_tag}' => 'Sale',
'{featured_tag}' => $featured,
'{rating}' => '5',
'{type == 0}' => ' ',
];
}
}
$content->content = str_replace($shortcodes, $shortcodes_data, $content->content);
return $content;
and this code that is stored in table
<div class="main">
<div class="child">
{id}
{p_name}
{p_slug}
{b_name}
{b_slug}
{img_src}
{sale_price}
{regural_price}
{sale_tag}
{featured_tag}
{rating}
{type == 0}
</div>
</div>
@Cronix @RamjithAp here is my code
and i want to just iterate child div after every product, not whole column
If you want to loop only child class div then in your content table you must save only this
<div class="child">
{id}
{p_name}
{p_slug}
{b_name}
{b_slug}
{img_src}
{sale_price}
{regural_price}
{sale_tag}
{featured_tag}
{rating}
{type == 0}
</div>
also your controller should loop the content as below
//here i am using Query For Getting Products
//make html codes
if(!empty($result)){
//shortcodes
$shortcodes[] = [
'{id}','{p_name}','{p_slug}','{b_name}','{b_slug}','{img_src}','{sale_price}','{regural_price}','{sale_tag}','{featured_tag}','{rating}','{type == 0}',
];
$temp_content = '';
foreach($result as $row){
if($row->featured_product == 0){
$featured = '<span class="tg-themetag" style="margin-left: 15px;">Featured</span>';
}else{
$featured = '';
}
//shortcodes_data
$shortcodes_data[] = [
'{id}' => $row->p_id,
'{p_name}' => $row->p_name,
'{p_slug}' => $row->p_slug,
'{b_name}' => $row->b_name,
'{b_slug}' => $row->b_slug,
'{img_src}' => URL('public/assets/user/images/ecommerce/products/'.$row->featured_image),
'{sale_price}' => $row->sale_price,
'{regural_price}' => $row->regural_price,
'{sale_tag}' => 'Sale',
'{featured_tag}' => $featured,
'{rating}' => '5',
'{type == 0}' => ' ',
];
$temp_content. = str_replace($shortcodes, $shortcodes_data, $content->content);
}
}
$content->content = $temp_content;
return $content;
@RamjithAp my home page is looking like something this, http://exprostudio.com/html/book_library/ so look on the sections like best selling,popular authors, pick by authors etc, so basically i want to iterate only products divs which is in section,
Please or to participate in this conversation.