Call a phtml template in a static block - magento

I want to call the "view.phtml" template in the tab "SPECIFICATION" (located in a static block), so that I can show a table of the grouped products.
Within that tab in the block content, I add following commands:
{{block type="catalog/product" template="catalog/product/view.phtml"}}
But nothing happens. I know the view.php located in catalog/product folder. Is there anything wrong with this command?
FYI,
in the "view.phtml", there is only one setence:
<?php echo $this->getChildHtml('product_type_data') ?>
And below is my "grouped.phtml", which is nothing but a table:
<?php $this->setPreconfiguredValue(); ?>
<?php $_product = $this->getProduct(); ?>
<?php $_associatedProducts = $this->getAssociatedProducts(); ?>
<?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
<?php echo $this->getChildHtml('product_type_data_extra') ?>
<div class="grouped-items-table-wrapper" style="border:0px;">
<table class="data-table grouped-items-table" id="super-product-table" style="width:75%;margin-left:10px;">
<tbody>
<tr style="background-color:#091f36;color:white;">
<td class="" colspan="2">
<p>
XCEL Part <br/>
No.
</p>
</td>
<td class="">
<p>
Fence <br/> H'
</p>
</td>
<td class="">
<p>
Fence <br/> W'
</p>
</td>
<td class="">
<p>
Fence<br/> H/mm
</p>
</td>
<td class="">
<p>
Fence <br/>W/mm
</p>
</td>
<td class="">
<p>
Pickets <br/>Qty.
</p>
</td>
<td class="">
<p>
Rails<br/> Qty.
</p>
</td>
<td class="">
<p>
Rings<br/> Qty.
</p>
</td>
<td class="">
<p>
Panel <br/>LB
</p>
</td>
<td class="">
<p>
Panel <br/>KG
</p>
</td>
</tr>
<?php if ($_hasAssociatedProducts): ?>
<?php foreach ($_associatedProducts as $_item): ?>
<?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
<tr>
<td class="" colspan="2">
<p>
<?= $_item->getSKU() ?>
</p>
</td>
<td class="">
<p>
<?= $_item->getAttributeText('height') ?>
</p>
</td>
<td class="">
<p>
<?= $_item->getAttributeText('width') ?>
</p>
</td>
<td class="">
<p>
<?= $var=ceil(($_item->getAttributeText('height'))/0.0032808) ?>
</p>
</td>
<td class="">
<p>
<?= $var=ceil(($_item->getAttributeText('width'))/0.0032808) ?>
</p>
</td>
<td class="">
<p>
20
</p>
</td>
<td class="">
<p>
<?= $_item->getAttributeText('rail') ?>
</p>
</td>
<td class="">
<p>
<?= $_item->getAttributeText('ring') ?>
</p>
</td>
<td class="">
<p>
<?= $var=round($_item->getWeight(), 2) ?>
</p>
</td>
<td class="">
<p>
<?= $var=round((($_item->getWeight())/2.2046),2) ?>
</p>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
<script type="text/javascript">decorateTable('super-product-table')</script>

{{block type="catalog/product_view" template="catalog/product/view.phtml"}}
As you mention you have defined inside catalog->product->view->view.php
In your block type you have defined "catalog/product_view" so your view.php file should be inside catalog->product->view.php

Related

Magento Review stars showing Empty in product

After reviewing the product I've just approved and on a single product page it shows comments but the rating star is not showing.
<?php $_votes = $_review->getRatingVotes(); ?>
<?php if (count($_votes)): ?>
<table class="ratings-table">
<col width="1" />
<col />
<tbody>
<?php foreach ($_votes as $_vote): ?>
<tr>
<th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
<td>
<div class="rating-box">
<div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>

Use angular expression within the same object with ngrepeat

just wondering if anyone knows how i can get an angular expression from within the ng-repeat, in the same object. eg
<!..This is the abgpankit..>
<div ng-repeat="equip in portal[0].equipment[0].sub" id="{{equip.id}}" class="displaydiv">
<div class="contentimg">
<h3>{{equip.item}}</h3>
</div>
<a ng-repeat="x in equip.links" href="#pdfdiv" onclick ="return iframeSrc("{{x.links}}");">
<li>{{x.desc}}</li></a>
<div class="information">
<p>{{equip.info}}</p>
</div>
<div class="items">
<table>
<tr>
<th>Items in Kit</th>
</tr>
<tr>
<td class="icons">
<a href="#panharness" class="panharnessicon">
<div class="iconimg">
<h2>Pan Harness</h2></div></a>
</td>
<td class="icons">
<a href="#displaymodule" class="displaymodicon">
<div class="iconimg">
<h2>Display Module</h2></div></a>
</td>
<td class="icons">
<a href="#halo" class="haloicon">
<div class="iconimg">
<h2>Halo</h2></div></a>
</td>
<td class="icons">
<a href="#edm" class="edmicon">
<div class="iconimg">
<h2>EDM</h2></div></a>
</td>
<td class="icons">
<a href="#dm" class="dmicon">
<div class="iconimg">
<h2>DM</h2></div></a>
</td>
<td class="icons">
<a href="#sft" class="sfticon">
<div class="iconimg">
<h2>SFT</h2></div></a>
</td>
</tr>
</table>
</div>
</div>
Sorry just changed it to the actually code from the site. I believe i have the syntax right, i just though there might be some limitation using an expression in the same object the ng-repeat is defined in.
Once i sort this out i can move further down and fix things up.
Cheers,
Mitchell

Display 5 stars for adding ratings instead of radio buttons

default magento will display the ratings as below image
but i want to change like this :
i am using default magento code
form.phtml [app/design/frontend/rwd/theme/template/review/form.phtml]
<?php if( $this->getRatings() && $this->getRatings()->getSize()): ?>
<h4><?php echo $this->__('Your Rating') ?> <em class="required"></em></h4>
<span id="input-message-box"></span>
<table class="data-table review-summary-table ratings" id="product-review-table">
<col width="1" />
<col />
<col />
<col />
<col />
<col />
<thead>
<tr>
<th> </th>
<th>
<div class="rating-box">
<span class="rating-number">1</span>
<span class="rating nobr" style="width:20%;"><?php echo $this->__('1 star') ?></span>
</div>
</th>
<th>
<div class="rating-box">
<span class="rating-number">2</span>
<span class="rating nobr" style="width:40%;"><?php echo $this->__('2 star') ?></span>
</div>
</th>
<th>
<div class="rating-box">
<span class="rating-number">3</span>
<span class="rating nobr" style="width:60%;"><?php echo $this->__('3 star') ?></span>
</div>
</th>
<th>
<div class="rating-box">
<span class="rating-number">4</span>
<span class="rating nobr" style="width:80%;"><?php echo $this->__('4 star') ?></span>
</div>
</th>
<th>
<div class="rating-box">
<span class="rating-number">5</span>
<span class="rating nobr" style="width:100%;"><?php echo $this->__('5 star') ?></span>
</div>
</th>
</tr>
</thead>
<tbody>
<?php foreach ($this->getRatings() as $_rating): ?>
<tr>
<th><?php echo $this->escapeHtml($_rating->getRatingCode()) ?></th>
<?php foreach ($_rating->getOptions() as $_option): ?>
<td class="value"><label for="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>"><input type="radio" name="ratings[<?php echo $_rating->getId() ?>]" id="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>" value="<?php echo $_option->getId() ?>" class="radio" /></label></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="validate_rating" class="validate-rating" value="" />
<script type="text/javascript">decorateTable('product-review-table')</script>
<?php endif; ?>
please help me to find solution
Thanks in advance
I recently dealt with it and my code looks something like this:
form.phtml
<?php foreach ($this->getRatings() as $_rating): ?>
<tr>
<th><?php echo $this->escapeHtml($_rating->getRatingCode()) ?>: </th>
<?php foreach ($_rating->getOptions() as $_option): ?>
<td class="value">
<label for="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>">
<input type="radio" name="ratings[<?php echo $_rating->getId() ?>]" id="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>" value="<?php echo $_option->getId() ?>" class="radio" />
<i class="fa fa-star"></i>
</label>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
*.css
.review-summary-table tbody td label input {
display: none;
}
// default
.review-summary-table tbody td label input + .fa {
color: #E6E6E6;
}
// hover, clicked, ...
.review-summary-table tbody td label:hover input + .fa,
.review-summary-table tbody td label input:checked + .fa,
.review-summary-table tbody td.active label input + .fa,
.review-summary-table tbody tr:hover td.tmp-active label input + .fa {
color: #50A4CF;
}
*.js
var reviewTable = $('#product-review-table');
if (reviewTable.length > 0) {
reviewTable.each(function() {
$(this).find('tbody tr').each(function() {
var row = $(this),
tdValues = row.find('td.value');
tdValues.each(function(index) {
$(this).find('label').hover(function() {
tdValues.removeClass('tmp-active');
tdValues.slice(0, index + 1).addClass('tmp-active');
}).click(function() {
tdValues.removeClass('active');
tdValues.slice(0, index + 1).addClass('active');
});
});
});
});
}

How to access only specific item instead of all page with nokogiri [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I'm trying to scrape some information from a site using Nokogiri.
The site looks like this:
<div class="content">
<article class="mainarticle">
<div class="breadcrump">
<ul></ul>
</div>
<div class="boxstyle">
<h2 style="margin-top:0.1em;">Fahrschulen mit Namen "Hugis Fahrschule AG"</h2>
</div>
<section class="leftrightleft ">
<header>
<div class="borderright borderbottom pads">
<figure class="logoschule">
<a href="fahrlehrerbilder.php?irat_id=14581" onclick="showGallery('irat_gallery',14581);return false;">
<img alt="Bilder Hugis Fahrschule AG" width="110" height="110" src="http://www.fahrlehrervergleich.ch/images/lehrer/small/fe1774780ba2d3aaa3e985ee960bf8.jpg">
<figcaption class="gallerylabel minhide">1 Bild</figcaption>
</a>
</figure>
<div>
<h3>Hugis Fahrschule AG</h3>
<h4 style="padding:0;line-height:1.3em;">Thomas Hugelshofer</h4>
<span class="biger">Thomas Hugelshofer</span>
<p><span>Oerlikon</span><br><span>Schaffhauserstrasse 443</span><br><span>8050</span> <span>Zürich</span></p>
<p>Karte Streetview </p>
<p></p>
</div>
<table class="eintraegemain clearfix">
<tbody>
<tr>
<td>Homepage:</td>
<td><span>www.hugis-fahrschule.ch</span></td>
</tr>
<tr>
<td>E-Mail:</td>
<td><a class="" href="kontakt_user.php?kontakt_id=14581" target="_blank" onclick="showEmailSender(14581);return false;">sekretariat#hugis-fahrschule.ch</a></td>
</tr>
<tr>
<td>Natel:</td>
<td><span>076 684 11 11</span></td>
</tr>
</tbody>
</table>
</div>
</header>
<div class="accordion">
<div class="accordion-section">
<a class="accordion-section-title accordeonfarbe-00" href="#accordion-1-14581"><span class="arrow"></span>Preise für Auto: ab 74.-, Auto Automat: ab 74.-, Motorrad: 90...</a>
<section id="accordion-1-14581" class="secondright accordion-section-content">
<div class="borderleft pads">
<table>
<tbody>
<tr>
<td>Kategorien</td>
<td>Preise CHF</td>
</tr>
<tr>
<td>Auto:</td>
<td>ab 74.-</td>
</tr>
<tr>
<td>Auto Automat:</td>
<td>ab 74.-</td>
</tr>
<tr>
<td>Motorrad:</td>
<td>90.-</td>
</tr>
<tr>
<td>Taxi:</td>
<td>74.-</td>
</tr>
<tr>
<td>Lastwagen:</td>
<td>165 .-</td>
</tr>
<tr>
<td>Lastwagen C1:</td>
<td>165.-</td>
</tr>
<tr>
<td>Auto Anhänger:</td>
<td>112.-</td>
</tr>
<tr>
<td>LKW Anhänger:</td>
<td>195.-</td>
</tr>
<tr>
<td>Car:</td>
<td>195.-</td>
</tr>
<tr>
<td style="font-weight:normal;">Lektionsdauer:</td>
<td style="font-weight:normal;">45 Minuten</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td>Kurse</td>
<td>Preise CHF</td>
</tr>
<tr>
<td>Verkehrskunde:</td>
<td>150.-</td>
</tr>
<tr>
<td>Nothelferkurs:</td>
<td>120.-</td>
</tr>
<tr>
<td>Motorrad Grundkurs:</td>
<td>160 pro Teil</td>
</tr>
<tr>
<td>Theorie:</td>
<td>Nach Anmeldung</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
<div class="accordion-section">
<a class="accordion-section-title accordeonfarbe-00" href="#accordion-2-14581"><span class="arrow"></span>Weitere Informationen: Sprachen: Deutsch, Englisch...</a>
<section id="accordion-2-14581" class="thirdleft accordion-section-content">
<div class="borderright pads">
<table id="sb_14581">
<tbody>
<tr>
<td>Sprachen: </td>
<td>Deutsch, Englisch, Serbisch, Albanisch, Türkisch, Polnisch, Italienisch</td>
</tr>
<tr>
<td>Autotyp:</td>
<td>Renauld Megan</td>
</tr>
<tr>
<td>Administration:</td>
<td>CHF 110.- (pauschal)</td>
</tr>
<tr>
<td>Jahrgang:</td>
<td>2015</td>
</tr>
<tr>
<td>Ausbildungsjahr:</td>
<td>2015</td>
</tr>
</tbody>
<tbody></tbody>
</table>
</div>
</section>
</div>
<footer class="clearfix">
<section>
<div class="bordertop pads" id="sbwl_14581">
<div class="ratingoutside">
<ul class="rating">
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li>(12)</li>
</ul>
</div>
<div class="rightbuts"><a class="buttonsmall" href="bewertungen.php?irat=14581" onclick="showBewe(14581);return false;" title="Bewertungen anschauen">Bewertungen anschauen</a>
<a class="buttonsmall" href="lernen/index.php?bewe_irat=14581">Fahrlehrer bewerten</a>
</div>
<p class="clicks minhide clearfix"> 30-Tage-Statistik : Inserat <span class="num_imp">14069</span> Mal angezeigt, Homepage <span class="num_click">228</span> Mal angeklickt. (sponsored)</p>
</div>
</section>
</footer>
</div>
</section>
<section class="leftrightleft ">
<header>
<div class="borderright borderbottom pads">
<div>
<h3>Hugis Fahrschule AG</h3>
<h4 style="padding:0;line-height:1.3em;">Thomas Hugelshofer</h4>
<span class="biger">Thomas Hugelshofer</span>
<p><span>8106</span> <span>Adlikon b. Regensdorf</span></p>
</div>
<table class="eintraegemain clearfix">
<tbody></tbody>
</table>
</div>
</header>
<div class="accordion">
<div class="accordion-section">
<a class="accordion-section-title accordeonfarbe-00" href="#accordion-1-13695"><span class="arrow"></span>Preise für Auto: 84.-, Motorrad: 90.-, Taxi: 95.-, Lastwagen:...</a>
<section id="accordion-1-13695" class="secondright accordion-section-content">
<div class="borderleft pads">
<table>
<tbody>
<tr>
<td>Kategorien</td>
<td>Preise CHF</td>
</tr>
<tr>
<td>Auto:</td>
<td>84.-</td>
</tr>
<tr>
<td>Motorrad:</td>
<td>90.-</td>
</tr>
<tr>
<td>Taxi:</td>
<td>95.-</td>
</tr>
<tr>
<td>Lastwagen:</td>
<td>165.-</td>
</tr>
<tr>
<td>Lastwagen C1:</td>
<td>165.-</td>
</tr>
<tr>
<td>Auto Anhänger:</td>
<td>112.-</td>
</tr>
<tr>
<td>LKW Anhänger:</td>
<td>195.-</td>
</tr>
<tr>
<td>Car:</td>
<td>195.-</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td>Kurse</td>
<td>Preise CHF</td>
</tr>
<tr>
<td>Verkehrskunde:</td>
<td>150.-</td>
</tr>
<tr>
<td>Motorrad Grundkurs:</td>
<td>160.-</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
<div class="accordion-section">
<a class="accordion-section-title accordeonfarbe-00" href="#accordion-2-13695"><span class="arrow"></span>Weitere Informationen: Sprachen: Deutsch, Englisch...</a>
<section id="accordion-2-13695" class="thirdleft accordion-section-content">
<div class="borderright pads">
<table id="sb_13695">
<tbody>
<tr>
<td>Sprachen: </td>
<td>Deutsch, Englisch, Französisch, Italienisch, Polnisch, Türkisch</td>
</tr>
<tr>
<td>Autotyp:</td>
<td>VW, BMW, MAN, SETRA, </td>
</tr>
</tbody>
<tbody></tbody>
</table>
</div>
</section>
</div>
<footer class="clearfix">
<section>
<div class="bordertop pads" id="sbwl_13695">
<div class="ratingoutside">
<ul class="rating">
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li class="icon icon-star-two"></li>
<li>(12)</li>
</ul>
</div>
<div class="rightbuts"><a class="buttonsmall" href="bewertungen.php?irat=13695" onclick="showBewe(13695);return false;" title="Bewertungen anschauen">Bewertungen anschauen</a>
<a class="buttonsmall" href="lernen/index.php?bewe_irat=13695">Fahrlehrer bewerten</a>
</div>
<p class="clicks minhide clearfix"> 30-Tage-Statistik : Inserat 307 Mal angezeigt. </p>
</div>
</section>
</footer>
</div>
</section>
<ul class="paginator"></ul>
<section class="texttabs clearfix">
<p>
Fahrschulen in der Schweiz: Fahrschulen und Fahrlehrer für Auto, Motorrad, Lastwagen, Taxi und Boot. Verkehrskunde (VKU), Nothelferkurs, Motorradgrundkurs. Informationen zu Strassenverkehrsamt, Lernfahrausweis, Fahrprüfung, WAB hier im Schweizer Fahrlehrervergleich.
</p>
<p>
Der Schweizer Fahrlehrervergleich gibt Auskunft über Fahrschulen und Fahrlehrer, die in folgenden Kategorien unterrichten: Auto, Motorrad, Lastwagen, Taxi und Boot. Ebenfalls werden Angaben über Verkehrtheorie, Motorradgrundkurs, Nothelferkurs und Theorietraining gemacht. Finden Sie eine Auto-, Motorrad- oder Lastwagen-Fahrschule, Informationen zu Ausbildung, Grundkurs, Theoriekurs, Schleuderkurs und Autoprüfung. Fahrschule Fahrschulen Fahrlehrer Zürich Bern Basel Luzern Aargau Schweiz. Der Schweizer Fahrlehrervergleich beinhaltet über 5000 Fahrschulen und Fahrlehrer aus der ganzen Schweiz.
</p>
</section>
</article>
<aside>
<h2>Fahrlehrer und Fahrschulen finden</h2>
<section class="filterbox regone boxstyle">
<h3>Fahrschulen </h3>
<ul>
<li><a title="Fahrschule Hugis Fahrschule AG" href="http://www.fahrlehrervergleich.ch/fahrschule-Hugis-Fahrschule-AG-Z%C3%BCrich-fahrschule-14581.htm">Hugis Fahrschule AG</a></li>
<li><a title="Fahrschule Hugis Fahrschule AG" href="http://www.fahrlehrervergleich.ch/fahrschule-Hugis-Fahrschule-AG-Adlikon+b.+Regensdorf-fahrschule-13695.htm">Hugis Fahrschule AG</a></li>
</ul>
</section>
<section class="filterbox regone boxstyle">
<h3>Sprachauswahl</h3>
<ul>
<li><a hreflang="de" href="http://www.fahrlehrervergleich.ch" title="Schweizer Fahrlehrervergleich">Schweizer Fahrlehrervergleich</a></li>
<li><a hreflang="fr" href="http://auto-ecole.comparatif.ch" title="Comparatif d'auto-écoles suisses">Comparatif d'auto-écoles suisses</a></li>
<li><a hreflang="it" href="http://autoscuola.comparazione.ch" title="Confronto delle autoscuole svizzere">Confronto delle autoscuole svizzere</a></li>
<li><a hreflang="en" href="http://driving-instructor.fahrlehrervergleich.ch" title="Swiss Driving Instructors">Swiss Driving Instructors</a></li>
</ul>
</section>
<section class="filterbox regone boxstyle">
<h3>Siehe auch...</h3>
<ul>
<li>
<a href="http://www.zahnarztvergleich.ch" title="Schweizer Zahnarztvergleich">
Schweizer Zahnarztvergleich </a>
</li>
<li>
<a href="http://www.treuhandvergleich.ch" title="Schweizer Treuhandvergleich">
Schweizer Treuhandvergleich </a>
</li>
<li>
<a href="http://www.anwaltvergleich.ch" title="Schweizer Anwaltvergleich">
Schweizer Anwaltvergleich </a>
</li>
<li>
<a href="http://www.coiffeurvergleich.ch" title="Schweizer Coiffeurvergleich">
Schweizer Coiffeurvergleich </a>
</li>
</ul>
</section>
</aside>
</div>
My code looks like this:
doc = Nokogiri::HTML(page)
doc.css(".leftrightleft").each do |item|
title = item.at_css("h3 a").text
address = item.at_css(".biger+ p , h3+ p")
address.search('br').each do |n|
n.replace(" ")
end
address = address.text
puts "-----"
puts title
puts "Address:"
puts address
puts "Course Types:"
item.css("table+ table tr+ tr").each do |type_price|
if type_price.css("td")[0] && type_price.css("td")[1] != nil
course_type = type_price.css("td")[0].text
course_type.gsub!(":", "")
price = type_price.css("td")[1].text
puts "\t #{course_type}: #{price}"
end
end
end
The problem is that when I do item.css("table+ table tr+ tr").each do |type_price| it's doing it for all items below that one and not only for that item in specific.
Can someone explain me what I'm doing wrong?
I've figured out a way to solve this.
Instead of making the loop like this item.css("table+ table tr+ tr").each do |type_price|, that makes it loop to the all page from item until the end of the page, I'm doing it like this item.at_css("table+ table tbody").css("tr+ tr").each.
With this solution I'm getting just the first table element and then I loop through the rest of the rows and it works.
I took a look and it seems that Nokogiri is jumbling the elements due to weird markup.
Switching to HTML5 is probably the best bet:
require 'nokogumbo'
doc = Nokogiri::HTML5.get(uri)
I should really say that libxml is doing the jumbling rather than Nokogiri.

How to add Pagination in laravel 5

I need to show one row per page.
this my contoller class code
public function showcontent($id)
{
$story=storybook::find($id);
$content=storycontent::where('titleid', $story['id'])->paginate(1);
//return $content;
return view('storyBook/viewStory',compact('story','content'));
}
this my view class code
#foreach($content as $content)
<?php $a=null; ?>
<?php $b=null; ?>
<?php $a=$content->file1; ?>
<?php $b=$content->file2; ?>
<table style="height: 330px;width: 680px;margin-top: 120px;margin-left: 50px">
<tr>
<td style="width: 340px"><img src="/{{$a}}" alt="Mountain View" style="width:330px;height:300px;"></td>
<td style="width: 340px"><img src="/{{$b}}" alt="Mountain View" style="width:330px;height:300px;"></td>
</tr>
</table>
<br>
#endforeach
In here i get only 1st row, rest of the rows not visible..
I do not know how to add pagination.
#foreach($content as $content)
So first of all change the naming of vars for example:
#foreach($content as $entry)
<table style="height: 330px;width: 680px;margin-top: 120px;margin-left: 50px">
<tr>
<td style="width: 340px"><img src="/{{$entry->file1}}" alt="Mountain View" style="width:330px;height:300px;"></td>
<td style="width: 340px"><img src="/{{$entry->file2}}" alt="Mountain View" style="width:330px;height:300px;"></td>
</tr>
</table>
<br>
#endforeach
$content->links()
As you can see I've added $content->links() after foreach loop. This is the method of Paginator that print out the pagination navigation.

Resources