PAYLAŞ
Joomla, introtext, frontpage, önsayfa, okunma, hits

Forumda bir üyemiz sormuş. Biraz kurcaladıktan sonra çözebildim. Anasayfasındaki haber özetinin altında o haberin okunma sayısını göstermek istiyordu. Hani mxcomment yorum bileşeninde mi ne var, haberin altında yorum yap, gönder, alıntıla, okunma sayısı diye yazar. Her neyse bu işlem benim bildiğimden biraz daha farklı olarak ön sayfa veri sorgusuna hits değerinin de çekilmesini gerektiriyormuş. Daha sonra bu değeri gösterebiliyorsunuz. Ben yarım saat kırkbeş dkika bu bilgiden yoksun tırmalayıp durdum. Neticede yapılacak işlemi burada aktarmak istedim.

Forumda bir üyemiz sormuş. Biraz kurcaladıktan sonra çözebildim. Anasayfasındaki haber özetinin altında o haberin okunma sayısını göstermek istiyordu. Hani mxcomment yorum bileşeninde mi ne var, haberin altında yorum yap, gönder, alıntıla, okunma sayısı diye yazar. Her neyse bu işlem benim bildiğimden biraz daha farklı olarak ön sayfa veri sorgusuna hits değerinin de çekilmesini gerektiriyormuş. Daha sonra bu değeri gösterebiliyorsunuz. Ben yarım saat kırkbeş dkika bu bilgiden yoksun tırmalayıp durdum. Neticede yapılacak işlemi burada aktarmak istedim.

Önce components/com_content/models/frontpage.php dosyasını açın  ve aşağıdaki sorguyu bulun:

components/com_content/models/frontpage.php dosyasında
 
$query = ' SELECT a.id, a.title, a.title_alias, a.introtext, a.fulltext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,' .
' a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.attribs, a.urls, a.metakey, a.metadesc, a.access,' .
' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,'.
' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug,'.
' CHAR_LENGTH( a.`fulltext` ) AS readmore,' .
' u.name AS author, u.usertype, g.name AS groups, cc.title AS category, s.title AS section, s.ordering AS s_ordering, cc.ordering AS cc_ordering, a.ordering AS a_ordering, f.ordering AS f_ordering'.
$voting['select'] .
' FROM #__content AS a' .
' INNER JOIN #__content_frontpage AS f ON f.content_id = a.id' .
' LEFT JOIN #__categories AS cc ON cc.id = a.catid'.
' LEFT JOIN #__sections AS s ON s.id = a.sectionid'.
' LEFT JOIN #__users AS u ON u.id = a.created_by' .
' LEFT JOIN #__groups AS g ON a.access = g.id'.
$voting['join'].
$where
.$orderby
;
 
RETURN $query;

 

Sorgunun başında hits değerinin de görülmesini isteyeceğiz. Bunun için bütün sorguya ihtiyacınız yok aslında. Sadece a.hits şeklinde ekleme yapmamız yeterli. Şöyle olacak, ilk satırdaki değişikliği görebilirsiniz:

 
$query = ' SELECT a.id, a.hits, a.title, a.title_alias, a.introtext, a.fulltext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,' .
' a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.attribs, a.urls, a.metakey, a.metadesc, a.access,' .
' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug,'.
' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug,'.
' CHAR_LENGTH( a.`fulltext` ) AS readmore,' .
' u.name AS author, u.usertype, g.name AS groups, cc.title AS category, s.title AS section, s.ordering AS s_ordering, cc.ordering AS cc_ordering, a.ordering AS a_ordering, f.ordering AS f_ordering'.
$voting['select'] .
' FROM #__content AS a' .
' INNER JOIN #__content_frontpage AS f ON f.content_id = a.id' .
' LEFT JOIN #__categories AS cc ON cc.id = a.catid'.
' LEFT JOIN #__sections AS s ON s.id = a.sectionid'.
' LEFT JOIN #__users AS u ON u.id = a.created_by' .
' LEFT JOIN #__groups AS g ON a.access = g.id'.
$voting['join'].
$where
.$orderby
;
 
RETURN $query;

 

Şimdi sıra okunma sayısını göstereceğimiz yere geldi.

components/com_content/views/frontpage/default_items.php dosyasını açıp şurayı bulun:

components/com_content/views/frontpage/default_items.php dosyası
 
<tr>
<td colspan="2">
<a href="<?php echo $this->item->readmore_link; ?>" class="readon<?php echo $this->item->params->get('pageclass_sfx'); ?>">
<?php if ($this->item->readmore_register) :
echo JText::_('Register to read more...');
elseif ($readmore = $this->item->params->get('readmore')) :
echo $readmore;
else :
echo JText::sprintf('Read more...');
endif; ?></a>
</td>
</tr>

Ardından </tr>’den evvel şunu ekleyin:

 
	<td class="readon" width="100px"><?php echo $this->item->hits; ?>&nbsp; sefer okundu</td>

Ben <td colspan=”2″> kısmını da <td> olarak değiştirdim ayrıca. Buna göre son durumu şöyle oldu o alanın:

 
<tr>
<td>
<a href="<?php echo $this->item->readmore_link; ?>" class="readon<?php echo $this->item->params->get('pageclass_sfx'); ?>">
<?php if ($this->item->readmore_register) :
echo JText::_('Register to read more...');
elseif ($readmore = $this->item->params->get('readmore')) :
echo $readmore;
else :
echo JText::sprintf('Read more...');
endif; ?></a>
</td>
<td class="readon" width="100px"><?php echo $this->item->hits; ?>&nbsp; sefer okundu</td>
</tr>

 

Yerelde örnek görüntü şu oldu.

joomla-introda-okunma-sayisi

Çekirdek dosyalarda yaptığınız değişiklikleri kesinlikle bir yere tam dosya yolu ve değişikliğin detaylı anlatımı şeklinde not etmeyi unutmayın. Güncellemelerde dönüp bakmanız gerekebilir.

Güle Güle kullanın.

 

 

BİR CEVAP BIRAK

Yorumunuzu ekleyin
Buraya adınızı yazın