I'm looking to define a specific attribute list by looking at the product id.
Currently I have the below, but I know it needs more work, especially as it's conflicting with the php within the enclosed divs.
Overall, I'd like it to say, if product id == 30 then display the following else display the norm.
Code is below.
<?php if($_product->getId() == "30")
{
<div class="attribute_page">
<p><span class="attribute_first">ISSN:</span> <?php echo $_product->getResource()->getAttribute('issn')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Editor:</span> <?php echo $_product->getResource()->getAttribute('editor')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Indexing Info:</span> <?php echo $_product->getResource()->getAttribute('indexing_info')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Scope of Journal:</span> <?php echo $_product->getResource()->getAttribute('scope_of_journal')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Purchasing Form:</span> <a href="<?php echo $_product->getResource()->getAttribute('purchasing_form')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Download Here</a></p>
<p><span class="attribute_first">Download Product Flyer:</span> <a href="<?php echo $_product->getResource()->getAttribute('product_flyer')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Download Here</a></p>
<p><span class="attribute_first">JSIS Homepage:</span> <a href="<?php echo $_product->getResource()->getAttribute('jsis')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<p><span class="attribute_first">Recommend to Librarian:</span> <a href="<?php echo $_product->getResource()->getAttribute('recommend_to_librarian')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('extrahint') ?>
</div>
}
else {
<div class="attribute_page">
<p><span class="attribute_first">Author:</span> <?php echo $_product->getResource()->getAttribute('author')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Translation:</span> <?php echo $_product->getResource()->getAttribute('translation')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Cover:</span> <?php echo $_product->getResource()->getAttribute('cover')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Google Books Preview:</span> <a href="<?php echo $_product->getResource()->getAttribute('google_preview')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('extrahint') ?>
</div>
<?php endif; ?>
Done it :) After some research, I was just missing a few characters. The new code looks like this.
<?php if($_product->getId() == 30): ?>
<div class="attribute_page">
<p><span class="attribute_first">ISSN:</span> <?php echo $_product->getResource()->getAttribute('issn')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Editor:</span> <?php echo $_product->getResource()->getAttribute('editor')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Indexing Info:</span> <?php echo $_product->getResource()->getAttribute('indexing_info')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Scope of Journal:</span> <?php echo $_product->getResource()->getAttribute('scope_of_journal')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Purchasing Form:</span> <a href="<?php echo $_product->getResource()->getAttribute('purchasing_form')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Download Here</a></p>
<p><span class="attribute_first">Download Product Flyer:</span> <a href="<?php echo $_product->getResource()->getAttribute('product_flyer')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Download Here</a></p>
<p><span class="attribute_first">JSIS Homepage:</span> <a href="<?php echo $_product->getResource()->getAttribute('jsis')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<p><span class="attribute_first">Recommend to Librarian:</span> <a href="<?php echo $_product->getResource()->getAttribute('recommend_to_librarian')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('extrahint') ?>
</div>
<?php else: ?>
<div class="attribute_page">
<p><span class="attribute_first">Author:</span> <?php echo $_product->getResource()->getAttribute('author')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Translation:</span> <?php echo $_product->getResource()->getAttribute('translation')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Cover:</span> <?php echo $_product->getResource()->getAttribute('cover')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Google Books Preview:</span> <a href="<?php echo $_product->getResource()->getAttribute('google_preview')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('extrahint') ?>
</div>
<?php endif; ?>
The first code would also work if you had provide <?php ?>
tag properly the code would go like this..
<?php if($_product->getId() == "30")
{ ?>
<div class="attribute_page">
<p><span class="attribute_first">ISSN:</span> <?php echo $_product->getResource()->getAttribute('issn')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Editor:</span> <?php echo $_product->getResource()->getAttribute('editor')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Indexing Info:</span> <?php echo $_product->getResource()->getAttribute('indexing_info')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Scope of Journal:</span> <?php echo $_product->getResource()->getAttribute('scope_of_journal')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Purchasing Form:</span> <a href="<?php echo $_product->getResource()->getAttribute('purchasing_form')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Download Here</a></p>
<p><span class="attribute_first">Download Product Flyer:</span> <a href="<?php echo $_product->getResource()->getAttribute('product_flyer')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Download Here</a></p>
<p><span class="attribute_first">JSIS Homepage:</span> <a href="<?php echo $_product->getResource()->getAttribute('jsis')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<p><span class="attribute_first">Recommend to Librarian:</span> <a href="<?php echo $_product->getResource()->getAttribute('recommend_to_librarian')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('extrahint') ?>
</div>
<?php }
else { ?>
<div class="attribute_page">
<p><span class="attribute_first">Author:</span> <?php echo $_product->getResource()->getAttribute('author')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Translation:</span> <?php echo $_product->getResource()->getAttribute('translation')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Cover:</span> <?php echo $_product->getResource()->getAttribute('cover')->getFrontend()->getValue($_product) ?></p>
<p><span class="attribute_first">Google Books Preview:</span> <a href="<?php echo $_product->getResource()->getAttribute('google_preview')->getFrontend()->getValue($_product) ?>" target="_blank" rel="nofollow">Click Here</a></p>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('extrahint') ?>
</div>
<?php } ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.