Skip to content

Commit 2195624

Browse files
Article Badge Fixes
1 parent 00d9e01 commit 2195624

File tree

5 files changed

+49
-111
lines changed

5 files changed

+49
-111
lines changed

astroid/astroid-framework/framework/article.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function showAuthorInfo()
257257
public function renderArticleBadge()
258258
{
259259
if ($this->showArticleBadge()) {
260-
$this->template->loadLayout('blog.modules.menuarticlebadge', true, ['article' => $this->article]);
260+
$this->template->loadLayout('blog.modules.badge', true, ['article' => $this->article]);
261261
}
262262
}
263263

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/**
4+
* @package Astroid Framework
5+
* @author JoomDev https://www.joomdev.com
6+
* @copyright Copyright (C) 2009 - 2019 JoomDev.
7+
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
8+
* DO NOT MODIFY THIS FILE DIRECTLY AS IT WILL BE OVERWRITTEN IN THE NEXT UPDATE
9+
* You can easily override all files under /frontend/ folder.
10+
* Just copy the file to ROOT/templates/YOURTEMPLATE/html/frontend/blog/ folder to create and override
11+
*/
12+
// No direct access.
13+
defined('_JEXEC') or die;
14+
extract($displayData);
15+
16+
$article = $params['article'];
17+
$params = $article->params;
18+
$badge = $params->get('astroid_article_badge', 0);
19+
if (!$badge) {
20+
return;
21+
}
22+
$type = $params->get('astroid_article_badge_type', 2);
23+
if ($type != 1) {
24+
?>
25+
<div class="article-badge article-badge-<?php echo $type; ?>"><?php echo \JText::_('ASTROID_ARTICLE_OPTIONS_BADGE_' . $type . '_LBL'); ?></div>
26+
<?php } else { ?>
27+
<div class="article-badge article-badge-1 article-badge-custom-<?php echo $article->id; ?>"><?php echo \JText::_($params->get('astroid_article_badge_text', '')); ?></div>
28+
<?php
29+
$color = $params->get('astroid_article_badge_text_color', '#fff');
30+
$bg = $params->get('astroid_article_badge_color', '#000');
31+
$style = '.article-badge.article-badge-custom-' . $article->id . '{color: ' . $color . '; background-color: ' . $bg . ';} .article-badge.article-badge-custom-' . $article->id . ':after{ border-left-color: ' . $bg . '}';
32+
$template->addStyleDeclaration($style);
33+
} ?>
Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
21
<?php
2+
33
/**
44
* @package Astroid Framework
55
* @author JoomDev https://www.joomdev.com
@@ -38,64 +38,9 @@
3838
if (is_string($image) && !empty($image)) {
3939
$astroidArticle->template->loadLayout('blog.modules.image', true, ['image' => $image, 'title' => $this->item->title]);
4040
}
41-
42-
$menulevel_article_badge = $this->params->get('astroid_articlebadge', 1);
43-
$astroidArticle->article->params->get('astroid_article_badge', 1);
44-
$astroid_article_badge = $template->params->get('astroid_article_badge', 1) ? ($astroidArticle->article->params->get('astroid_article_badge', 0) ? 1 : 0) : 0;
45-
$astroidlevel_article_badge = $template->params->get('astroid_badge', 1);
4641
?>
47-
<div class="card-body<?php echo $tpl_params->get('show_post_format') ? ' has-post-format' : ''; ?><?php echo $astroid_article_badge ? ' has-badge' : ''; ?><?php echo (!empty($image) ? ' has-image' : ''); ?>">
48-
<?php if($astroidArticle->article->params->get('astroid_article_badge', 1)){ ?>
49-
<?php switch ($menulevel_article_badge) {
50-
case "2":
51-
if(($astroidlevel_article_badge == 3) || ($astroidlevel_article_badge==1)) {
52-
53-
if ($astroidArticle->article->params->get('astroid_article_badge', 0)) { ?>
54-
<?php
55-
if ($astroidArticle->article->params->get('astroid_article_badge_type', 2) == 1) {
56-
$style = '.article-badge.article-badge-custom.article-id-'.$this->item->id.':after{ border-left-color: ' . $astroidArticle->article->params->get('astroid_article_badge_color', '#000'). '} .article-badge.article-badge-custom.article-id-'.$this->item->id.':before{ border-bottom-color: ' . $astroidArticle->article->params->get('astroid_article_badge_color', '#000'). '; }';
57-
$document->addStyleDeclaration($style);
58-
?>
59-
<div style="background: <?php echo $astroidArticle->article->params->get('astroid_article_badge_color', '#000'); ?>; color: <?php echo $astroidArticle->article->params->get('astroid_article_badge_text_color', '#000'); ?>" class="article-badge article-badge-<?php
60-
if ($astroidArticle->article->params->get('astroid_article_badge_type', 2) == 1) {
61-
echo 'custom article-id-'.$this->item->id;
62-
} else {
63-
echo $astroidArticle->article->params->get('astroid_article_badge_type', 2);
64-
}
65-
?>"><?php echo JText::_($astroidArticle->article->params->get('astroid_article_badge_text', '')); ?></div>
66-
<?php } else { ?>
67-
<div class="article-badge article-badge-<?php echo $astroidArticle->article->params->get('astroid_article_badge_type', 2); ?>">
68-
<?php $astroidArticle->renderArticleBadge(); ?>
69-
<?php echo JText::_('ASTROID_ARTICLE_OPTIONS_BADGE_' . ($astroidArticle->article->params->get('astroid_article_badge_type', 2)) . '_LBL'); ?></div>
70-
<?php } ?>
71-
<?php } ?>
72-
<?php
73-
}
74-
break;
75-
case 1 :
76-
77-
if ($astroidArticle->article->params->get('astroid_article_badge_type', 2) == 1) {
78-
$style = '.article-badge.article-badge-custom.article-id-'.$this->item->id.':after{ border-left-color: ' . $astroidArticle->article->params->get('astroid_article_badge_color', '#000'). '} .article-badge.article-badge-custom.article-id-'.$this->item->id.':before{ border-bottom-color: ' . $astroidArticle->article->params->get('astroid_article_badge_color', '#000'). '; }';
79-
$document->addStyleDeclaration($style);
80-
?>
81-
<div style="background: <?php echo $astroidArticle->article->params->get('astroid_article_badge_color', '#000'); ?>; color: <?php echo $astroidArticle->article->params->get('astroid_article_badge_text_color', '#000'); ?>" class="article-badge article-badge-<?php
82-
if ($astroidArticle->article->params->get('astroid_article_badge_type', 2) == 1) {
83-
echo 'custom article-id-'.$this->item->id;
84-
} else {
85-
echo $astroidArticle->article->params->get('astroid_article_badge_type', 2);
86-
}
87-
?>"><?php echo JText::_($astroidArticle->article->params->get('astroid_article_badge_text', '')); ?></div>
88-
<?php } else { ?>
89-
<div class="article-badge article-badge-<?php echo $astroidArticle->article->params->get('astroid_article_badge_type', 2); ?>">
90-
<?php $astroidArticle->renderArticleBadge(); ?>
91-
<?php echo JText::_('ASTROID_ARTICLE_OPTIONS_BADGE_' . ($astroidArticle->article->params->get('astroid_article_badge_type', 2)) . '_LBL'); ?></div>
92-
<?php } ?>
93-
94-
<?php
95-
break;
96-
}
97-
}
98-
?>
42+
<div class="card-body<?php echo $tpl_params->get('show_post_format') ? ' has-post-format' : ''; ?><?php echo (!empty($image) ? ' has-image' : ''); ?>">
43+
<?php $astroidArticle->renderArticleBadge(); ?>
9944
<div class="article-title item-title">
10045
<?php echo JLayoutHelper::render('joomla.content.blog_style_default_item_title', $this->item); ?>
10146
</div>
@@ -106,7 +51,8 @@
10651
<div class="article-intro-text"><?php echo $this->item->introtext; ?></div>
10752
<?php if ($info == 1 || $info == 2) : ?>
10853
<?php if ($useDefList) : ?>
109-
<?php // Todo: for Joomla4 joomla.content.info_block.block can be changed to joomla.content.info_block ?>
54+
<?php // Todo: for Joomla4 joomla.content.info_block.block can be changed to joomla.content.info_block
55+
?>
11056
<?php echo JLayoutHelper::render('joomla.content.info_block.block', array('item' => $this->item, 'params' => $params, 'astroidArticle' => $astroidArticle, 'position' => 'below')); ?>
11157
<?php endif; ?>
11258
<?php endif; ?>
@@ -138,4 +84,4 @@
13884
<?php if ($params->get('show_tags') && !empty($this->item->tags->itemTags)) : ?>
13985
<?php echo JLayoutHelper::render('joomla.content.tags', $this->item->tags->itemTags); ?>
14086
<?php endif; ?>
141-
<?php echo $this->item->event->afterDisplayContent; ?>
87+
<?php echo $this->item->event->afterDisplayContent; ?>

astroid/astroid-template-zero/html/com_content/featured/default_item.php

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @package Astroid Framework
45
* @author JoomDev https://www.joomdev.com
@@ -37,55 +38,9 @@
3738
if (is_string($image) && !empty($image)) {
3839
$astroidArticle->template->loadLayout('blog.modules.image', true, ['image' => $image, 'title' => $this->item->title]);
3940
}
40-
$astroid_article_badge = $template->params->get('astroid_article_badge', 1) ? ($astroidArticle->article->params->get('astroid_article_badge', 0) ? 1 : 0) : 0;
41-
$menulevel_article_badge = $this->params->get('astroid_articlebadge', 1);
42-
$astroid_article_badge1 = $template->params->get('astroid_badge', 1);
4341
?>
44-
<div class="card-body<?php echo $tpl_params->get('show_post_format') ? ' has-post-format' : ''; ?><?php echo $astroid_article_badge ? ' has-badge' : ''; ?><?php echo (!empty($image) ? ' has-image' : ''); ?>">
45-
<?php
46-
switch ($menulevel_article_badge){
47-
case 2:
48-
if(($astroid_article_badge1 == 3) || ($astroid_article_badge1 == 1)) {
49-
if ($astroidArticle->article->params->get('astroid_article_badge', 0)) { ?>
50-
<?php
51-
if ($astroidArticle->article->params->get('astroid_article_badge_type', 2) == 1) {
52-
$style = '.article-badge.article-badge-custom.article-id-'.$this->item->id.':after{ border-left-color: ' . $astroidArticle->article->params->get('astroid_article_badge_color', '#000'). '} .article-badge.article-badge-custom.article-id-'.$this->item->id.':before{ border-bottom-color: ' . $astroidArticle->article->params->get('astroid_article_badge_color', '#000'). '; }';
53-
$document->addStyleDeclaration($style);
54-
?>
55-
<div style="background: <?php echo $astroidArticle->article->params->get('astroid_article_badge_color', '#000'); ?>; color: <?php echo $astroidArticle->article->params->get('astroid_article_badge_text_color', '#000'); ?>" class="article-badge article-badge-<?php
56-
if($astroidArticle->article->params->get('astroid_article_badge_type', 2) == 1){
57-
echo 'custom article-id-'.$this->item->id;
58-
} else {
59-
echo $astroidArticle->article->params->get('astroid_article_badge_type', 2);
60-
}
61-
?>"><?php echo JText::_($astroidArticle->article->params->get('astroid_article_badge_text', '')); ?></div>
62-
<?php } else { ?>
63-
<div class="article-badge article-badge-<?php echo $astroidArticle->article->params->get('astroid_article_badge_type', 2); ?>"><?php echo JText::_('ASTROID_ARTICLE_OPTIONS_BADGE_' . ($astroidArticle->article->params->get('astroid_article_badge_type', 2)) . '_LBL'); ?></div>
64-
<?php } ?>
65-
<?php } ?>
66-
<?php }
67-
break ;
68-
case 1:
69-
if ($astroidArticle->article->params->get('astroid_article_badge', 0)) { ?>
70-
<?php
71-
if ($astroidArticle->article->params->get('astroid_article_badge_type', 2) == 1) {
72-
$style = '.article-badge.article-badge-custom.article-id-'.$this->item->id.':after{ border-left-color: ' . $astroidArticle->article->params->get('astroid_article_badge_color', '#000'). '} .article-badge.article-badge-custom.article-id-'.$this->item->id.':before{ border-bottom-color: ' . $astroidArticle->article->params->get('astroid_article_badge_color', '#000'). '; }';
73-
$document->addStyleDeclaration($style);
74-
?>
75-
<div style="background: <?php echo $astroidArticle->article->params->get('astroid_article_badge_color', '#000'); ?>; color: <?php echo $astroidArticle->article->params->get('astroid_article_badge_text_color', '#000'); ?>" class="article-badge article-badge-<?php
76-
if($astroidArticle->article->params->get('astroid_article_badge_type', 2) == 1){
77-
echo 'custom article-id-'.$this->item->id;
78-
} else {
79-
echo $astroidArticle->article->params->get('astroid_article_badge_type', 2);
80-
}
81-
?>"><?php echo JText::_($astroidArticle->article->params->get('astroid_article_badge_text', '')); ?></div>
82-
<?php } else { ?>
83-
<div class="article-badge article-badge-<?php echo $astroidArticle->article->params->get('astroid_article_badge_type', 2); ?>"><?php echo JText::_('ASTROID_ARTICLE_OPTIONS_BADGE_' . ($astroidArticle->article->params->get('astroid_article_badge_type', 2)) . '_LBL'); ?></div>
84-
<?php } ?>
85-
<?php }
86-
break;
87-
} ?>
88-
42+
<div class="card-body<?php echo $tpl_params->get('show_post_format') ? ' has-post-format' : ''; ?><?php echo (!empty($image) ? ' has-image' : ''); ?>">
43+
<?php $astroidArticle->renderArticleBadge(); ?>
8944
<div class="item-title">
9045
<?php echo JLayoutHelper::render('joomla.content.blog_style_default_item_title', $this->item); ?>
9146
</div>
@@ -96,7 +51,8 @@
9651
<?php echo $this->item->introtext; ?>
9752
<?php if ($info == 1 || $info == 2) : ?>
9853
<?php if ($useDefList) : ?>
99-
<?php // Todo: for Joomla4 joomla.content.info_block.block can be changed to joomla.content.info_block ?>
54+
<?php // Todo: for Joomla4 joomla.content.info_block.block can be changed to joomla.content.info_block
55+
?>
10056
<?php echo JLayoutHelper::render('joomla.content.info_block.block', array('item' => $this->item, 'params' => $params, 'astroidArticle' => $astroidArticle, 'position' => 'below')); ?>
10157
<?php endif; ?>
10258
<?php endif; ?>
@@ -128,4 +84,4 @@
12884
<?php if ($params->get('show_tags') && !empty($this->item->tags->itemTags)) : ?>
12985
<?php echo JLayoutHelper::render('joomla.content.tags', $this->item->tags->itemTags); ?>
13086
<?php endif; ?>
131-
<?php echo $this->item->event->afterDisplayContent; ?>
87+
<?php echo $this->item->event->afterDisplayContent; ?>

astroid/astroid-template-zero/scss/astroid/components/_badge.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@
124124
left: 0;
125125
}
126126
}
127+
~ .article-title{
128+
margin-top: $article-badge-height + 5px;
129+
}
127130
}
128131

129132
.card-body {

0 commit comments

Comments
 (0)