News Show Pro GK5 & Writer Template j3.0 - Adding Short Description in popup from article content. Using jQuery.
Please update to latest News Show Pro GK5 for j3. Versions used NSP j3.0 v1.6.4, GK John Template v3.13
Edited files are attached to this post however as template and module files gets updated I won't be able to update the files all the time so follow below changes when you do update your files.
Update: Added readmore link to end of description linking to article.
See controller.php Line 74 changes.
See script.jquery.js Line 127 changes.
How it would look :
Following files will be edited. Backup before editing please.
- Code: Select all
\modules\mod_news_pro_gk5\portal_modes\portfolio2\controller.php
\modules\mod_news_pro_gk5\portal_modes\portfolio2\script.jquery.js
\modules\mod_news_pro_gk5\portal_modes\portfolio2\style.css
\templates\gk_john_s\css\gk.stuff.css
\language\en-GB\en-GB.mod_news_pro_gk5.ini
1. Changes to "controller.php".
Open file:
- Code: Select all
\modules\mod_news_pro_gk5\portal_modes\portfolio2\controller.php
Find Line: 74 which is below.
- Code: Select all
data-img="'.strip_tags($this->get_image($i)).'"';
Replace it with below code
- Code: Select all
data-img="'.strip_tags($this->get_image($i)).'"
data-desc-text="'.JText::_('MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO2_DATE_DESC_TEXT').'"
data-readmore-text="'.JText::_('MOD_NEWS_PRO_GK5_NSP_READMORE').'"
data-desc="'.implode(' ', array_slice(explode(' ', strip_tags($this->parent->content[$i]['text'])), 0, 30)).'... "';';
See number 30 at the end of the code, that is the number of word it would cut out from, so change that to your required word limit.
Save and close the file.
2. Changes to "script.jquery.js".
Find Line: 36 which is below.
- Code: Select all
var popup_content = '<a href="#" class="gkPortfolioPrev">«</a><a href="#" class="gkPortfolioNext">»</a><a href="#" class="gkPortfolioClose">×</a><div><div class="gkPortfolioImage"></div><div class="gkPortfolioDesc"><h3 class="gkPortfolioTitle"></h3><small class="gkPortfolioCategory"></small><span class="gkPortfolioAuthor"></span><span class="gkPortfolioDate"></span></div></div>';
Replace it with below code.
- Code: Select all
var popup_content = '<a href="#" class="gkPortfolioPrev">«</a><a href="#" class="gkPortfolioNext">»</a><a href="#" class="gkPortfolioClose">×</a><div><div class="gkPortfolioImage"></div><div class="gkPortfolioDesc"><h3 class="gkPortfolioTitle"></h3><small class="gkPortfolioCategory"></small><span class="gkPortfolioAuthor"></span><span class="gkPortfolioDate"></span><span class="gkPortfolioDescText"></span></div></div>';
Find Line: 46 which is below.
- Code: Select all
var popup_date = popup.find('.gkPortfolioDate');
Replace it with below code.
- Code: Select all
var popup_date = popup.find('.gkPortfolioDate');
var popup_desc = popup.find('.gkPortfolioDescText');
Find Line: 58 which is below
- Code: Select all
popup_date.removeClass('active');
Replace it with below code.
- Code: Select all
popup_date.removeClass('active');
popup_desc.removeClass('active');
Find Line: 76 which is below
- Code: Select all
popup_date.removeClass('active');
Replace it with below code
- Code: Select all
popup_date.removeClass('active');
popup_desc.removeClass('active');
Find Line: 103 which is below
- Code: Select all
popup_date.removeClass('active');
Replace it with below code
- Code: Select all
popup_date.removeClass('active');
popup_desc.removeClass('active');
Find Line: 127 which is below
- Code: Select all
popup_date.html('<span>' + img.attr('data-date-text') + '</span>' + img.attr('data-date'));
Replace it with below code.
- Code: Select all
popup_date.html('<span>' + img.attr('data-date-text') + '</span>' + img.attr('data-date'));
popup_desc.html('<span>' + img.attr('data-desc-text') + '</span>' + img.attr('data-desc') + '<a class="gkReadmore" href="' + img.attr('href') + '">' + img.attr('data-readmore-text') +'</a>');
Find Lines: 139 to 142 which is below
- Code: Select all
setTimeout(function() {
popup_date.addClass('active');
blank = false;
}, 500);
Replace it with below code
- Code: Select all
setTimeout(function() { popup_date.addClass('active'); }, 500);
setTimeout(function() { popup_desc.addClass('active');
blank = false;
}, 500);
Save and close the file.
3. Changes to modules "style.css".
Add following css code to end of style.css file.
- Code: Select all
.gkNspPM-Portfolio2 .gkPortfolioDescText {
display: block;
margin: 0 0 24px 0;
opacity: 0;
top: 50px;
position: relative;
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-ms-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
}
.gkNspPM-Portfolio2 .gkPortfolioDescText {
border-top: 1px solid #ddd;
font-size: 15px;
padding-top: 12px;
}
.gkNspPM-Portfolio2 .gkPortfolioDescText span {
color: #aaa;
display: block;
font-size: 12px;
line-height: 1;
margin: 0 0 3px 0;
}
.gkNspPM-Portfolio2 .gkPortfolioDescText.active {
opacity: 1;
top: 0;
}
@media (max-width: 840px) {
.gkNspPM-Portfolio2 .gkPortfolioDescText {
font-size: 12px;
padding: 10px 0;
}
}
4. Changes to "gk.stuff.css"
Add following css code to gk.stuff.css
- Code: Select all
.gkNspPM-Portfolio2 .gkPortfolioDescText {
display: block;
margin: 0;
opacity: 0;
top: 50px;
position: relative;
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-ms-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
}
.gkNspPM-Portfolio2 .gkPortfolioDescText {
border-top: 1px solid #ddd;
font-size: 15px;
padding: 16px 0;
}
.gkNspPM-Portfolio2 .gkPortfolioDescText span {
color: #aaa;
display: block;
font-size: 12px;
line-height: 1;
margin: 0 0 3px 0;
}
.gkNspPM-Portfolio2 .gkPortfolioDescText.active {
opacity: 1;
top: 0;
}
5. Changes to "en-GB.mod_news_pro_gk5.ini".
Add following string to end of file.
- Code: Select all
MOD_NEWS_PRO_GK5_PORTAL_MODE_PORTFOLIO2_DATE_DESC_TEXT="Description:"
That's it. It should work now regardless of data source, K2 or Joomla.