ongeremd.com

Blog over het Fine tunen van website, webshops en Content management systemen

Nieuws weergeven in magento webshop

Het ingebouwde cms systeem is eigenlijk niet helemaal geschikt om nieuws te publiceren in de voorpagina van je magento webshop.

Zeker als je een webshop opzet voor een klant die hierna graag zelf het nieuws wil toevoegen aan zijn voorpagina.

Het is natuurlijk weer niet zo heel gemakkelijk en komen we er niet zonder code schrijven vanaf.
Gelukkig is het systeem van magento zo modulair opgebouwd dat je eigenlijk wel weet dat je iets van code moet toevoegen om het blok weer te geven op de website .

Installeren van deze magento extension kan middels de onderstaande extension key.

extension-key:

magento-community/MWD_News_and_Testimonials_with_Images_Extension

Na installatie kun vindt je in het admin gedeelte de volgende opties:

Under the admin menu CMS you can find new menus to manage:

News: CMS > News
Testimonials: CMS > Testimonials
Press Releases: CMS > Press Releases
Press Articles: CMS > Press Articles

De pagina’s zijn gemakkelijk aan te passen door bewerking van de files op de onderstaande locatie

News
/app/design/frontend/your_theme/default/template/profile/news.phtml
/app/design/frontend/your_theme/default/template/profile/readnews.phtml
Press Articles
/app/design/frontend/your_theme/default/template/profile/pressarticles.phtml
Press Releases
/app/design/frontend/your_theme/default/template/profile/pressreleases.phtml
/app/design/frontend/your_theme/default/template/profile/readpressrelease.phtml
Testimonials
/app/design/frontend/your_theme/default/template/profile/testimonials.phtml

Het weergeven van het nieuws op de homepage van magento webshop

Go to /app/design/frontend/default/default/template/profile an download the filenews.phtml
Open the file and change the code on line 20:
<?php $newsUrl = $this->getUrl(’*/*/read’, array(”id” => $n->getData(”profile_id”)));?>
To
<?php $newsUrl = $this->getUrl(’profile/news/read’, array(”id” => $n->getData(”profile_id”)));?>
This will update the “Continue reading…” link.

Rename and safe the file as news-front.phtml Upload the file to: /app/design/frontend/default/default/template/profile

Go into the backend to CMS and open your home page.
Put the next code into the content of your homepage: {{block type=”profile/profile” name=”profile” template=”profile/news.phtml”}} and save the page

Reload your homepage. Congratulations the news items are displayed on the frontend of your web shop!

Limiting the news on the frontpage.
<?php $cnt=0; foreach($news as $n): ?>
<?php if ($n->getData(”is_active”)):?>
<div class=”ColumnLeft” style=”float: left; border-bottom: 1px solid #ddd; padding-bottom: 10px; padding-top: 10px; width: 400px;”>
<?php $newsUrl = $this->getUrl(’profile/news/read’, array(”id” => $n->getData(”profile_id”)));?>
<?php if($n->getData(”thumbnail”)):?>
<a href=”<?echo $newsUrl ?>”>
<?php $marginPosition = ($n->getThumbnailAlign() == “left”) ? “float: left; margin-right: 10px;” : “float: right; margin-left: 10px;”;?>
<img src=”<?php echo $n->getThumbnailResize(100) ?>” style=”<?php echo $marginPosition; ?>”/>
</a>
<?php endif; ?>
<a href=”<?echo $newsUrl ?>”><h2><?php echo $this->formatDate($n->getData(”creation_time”)); ?> - <?php echo $n->getData(”content_heading”); ?></h2></a>
<p><?php echo $n->getContent(256); ?></p>
<?php if(strlen($n->getData(”content”)) > 256 ): ?>
<p align=”right”><a href=”<?php echo $newsUrl ?>” ><?php echo $this->__(’Continue reading…’) ?></a></p>
<?php endif;?>
</div>
<div class=clearFloat></div>
<?php endif; ?>
<?php $cnt++; if ($cnt>=1) break; ?>
<?php endforeach; ?>
<p align=”right”><a href=”<?php echo $this->getUrl(’profile/news’) ?>” title=”<?php echo $this->__(’Read All’) ?>”><?php echo $this->__(’Read All’) ?></a></p>
change the value for cnt and make it your desired number.

<!–[if gte mso 10]–>
< ! /* Style Definitions */ table.MsoNormalTable {mso-style-name:Standaardtabel; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:”"; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:”Times New Roman”; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} > magento-community/MWD_News_and_Testimonials_with_Images_Extension

Hoe is het nieuws weer te geven op de voorpagina van magento web shop:
Ga naar /app/design/frontend/default/default/template/profile en download de file : filenews.phtml Open de file en verander de code op regel 20 van :
<?php $newsUrl = $this->getUrl(’*/*/read’, array(”id” => $n->getData(”profile_id”)));?>
Naar
<?php $newsUrl = $this->getUrl(’profile/news/read’, array(”id” => $n->getData(”profile_id”)));?>
Dit zal de “Continue reading” link updaten.
Hernoem de file en sla hem op als news-front.phtml.
Upload de file naar /app/design/frontend/default/default/template/profile
Ga in het backend naar cms en open je homepage.
Voeg de volgende code toe aan de content van je homepage.
{{block type=”profile/profile” name=”profile” template=”profile/news-front.phtml”}} and save the page
refresh je homepage en het nieuws zal worden weergegeven op de homepage.
Het is helemaal klaar met installeren en er staan zelfs voorbeeld nieuwsberichten in .
Op de voorpagina kun je het nieuws blok benaderen via de linken:
News http://www.yourmagentostore.com/profile/news
Testimonials http://www.yourmagentostore.com/profile/testimonials
Press Releases http://www.yourmagentostore.com/profile/pressreleases
Press Articles http://www.yourmagentostore.com/profile/pressarticles
Maak je in je magento store gebruik van een eigen theme , kopieer dan de onderstaande files naar je thema folder
/app/design/frontend/default/default/layout/profile.xml > /app/design/frontend/your_theme/default/layout/profile.xml
/app/design/frontend/default/default/template/profile > /app/design/frontend/your_theme/default/template/profile

Customization

Bekijk ook


Leave a Reply