Skip to content

Commit

Permalink
[mod_feed] Add date to layout & options (#18213)
Browse files Browse the repository at this point in the history
* [mod_feed] Add date to layout & options

PR for #14300

Adds two new options to the module to optionally display the feed and item dates

### Test instructions
Create a new module to display a feed
To test you can use this feed http://www.feedforall.com/blog-feed.xml

Check to ensure that the TWO date options are set to NO by default and publish the module

Check the module on the front end and you will see a regular field as before this PR

Now enable the Date options and you will see a date for the feed and a date for each item

* codestyle

* and admin module

* corrections thanks @Quy

* oop

thanks @Quy

* oops

Thanks @Quy

* thanks

@Quy like this?

* thanks

hope i understood you @Quy

* Update default.php

* Update default.php
  • Loading branch information
brianteeman authored and Michael Babker committed May 12, 2018
1 parent de9d0ea commit cf9c6c6
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 3 deletions.
4 changes: 4 additions & 0 deletions administrator/language/en-GB/en-GB.mod_feed.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ MOD_FEED="Feed Display"
MOD_FEED_ERR_CACHE="Please make cache folder writable."
MOD_FEED_ERR_NO_URL="No feed URL specified."
MOD_FEED_ERR_FEED_NOT_RETRIEVED="Feed not found."
MOD_FEED_FIELD_DATE_DESC="Show the publication date of the feed."
MOD_FEED_FIELD_DATE_LABEL="Feed Date"
MOD_FEED_FIELD_DESCRIPTION_DESC="Show the description text for the whole Feed."
MOD_FEED_FIELD_DESCRIPTION_LABEL="Feed Description"
MOD_FEED_FIELD_IMAGE_DESC="Show the image associated with the whole feed."
MOD_FEED_FIELD_IMAGE_LABEL="Feed Image"
MOD_FEED_FIELD_ITEMDATE_DESC="Show the publication date of individual RSS Items."
MOD_FEED_FIELD_ITEMDATE_LABEL="Publication Date"
MOD_FEED_FIELD_ITEMDESCRIPTION_DESC="Show the Description or Intro text of individual RSS Items."
MOD_FEED_FIELD_ITEMDESCRIPTION_LABEL="Item Description"
MOD_FEED_FIELD_ITEMS_DESC="Enter number of RSS items to display."
Expand Down
24 changes: 24 additions & 0 deletions administrator/modules/mod_feed/mod_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
<option value="0">JNO</option>
</field>

<field
name="rssdate"
type="radio"
label="MOD_FEED_FIELD_DATE_LABEL"
description="MOD_FEED_FIELD_DATE_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>

<field
name="rssdesc"
type="radio"
Expand Down Expand Up @@ -100,6 +112,18 @@
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>

<field
name="rssitemdate"
type="radio"
label="MOD_FEED_FIELD_ITEMDATE_LABEL"
description="MOD_FEED_FIELD_ITEMDATE_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>

<field
name="word_count"
Expand Down
14 changes: 12 additions & 2 deletions administrator/modules/mod_feed/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@
<div style="direction: <?php echo $rssrtl ? 'rtl' :'ltr'; ?>; text-align: <?php echo $rssrtl ? 'right' :'left'; ?> !important" class="feed<?php echo $moduleclass_sfx; ?>">
<?php

// Feed description
// Feed title
if (!is_null($feed->title) && $params->get('rsstitle', 1)) : ?>
<h2 class="<?php echo $direction; ?>">
<a href="<?php echo str_replace('&', '&amp;', $rssurl); ?>" target="_blank">
<?php echo $feed->title; ?></a>
</h2>
<?php endif;
// Feed date
if ($params->get('rssdate', 1)) : ?>
<h3>
<?php echo JHtml::_('date', $feed->publishedDate, JText::_('DATE_FORMAT_LC3')); ?>
</h3>
<?php endif; ?>

<!-- Feed description -->
Expand Down Expand Up @@ -95,7 +101,11 @@
<?php else : ?>
<h5 class="feed-link"><?php echo $feed[$i]->title; ?></h5>
<?php endif; ?>

<?php if ($params->get('rssitemdate')) : ?>
<div class="feed-item-date">
<?php echo JHtml::_('date', $feed[$i]->publishedDate, JText::_('DATE_FORMAT_LC3')); ?>
</div>
<?php endif; ?>
<?php if ($params->get('rssitemdesc') && !empty($text)) : ?>
<div class="feed-item-description">
<?php
Expand Down
4 changes: 4 additions & 0 deletions language/en-GB/en-GB.mod_feed.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ MOD_FEED="Feed Display"
MOD_FEED_ERR_CACHE="Please make cache folder writeable."
MOD_FEED_ERR_FEED_NOT_RETRIEVED="Feed not found."
MOD_FEED_ERR_NO_URL="No feed URL specified."
MOD_FEED_FIELD_DATE_DESC="Show the publication date of the feed."
MOD_FEED_FIELD_DATE_LABEL="Feed Date"
MOD_FEED_FIELD_DESCRIPTION_DESC="Show the description text for the entire feed."
MOD_FEED_FIELD_DESCRIPTION_LABEL="Feed Description"
MOD_FEED_FIELD_IMAGE_DESC="Show the image associated with the entire feed."
MOD_FEED_FIELD_IMAGE_LABEL="Feed Image"
MOD_FEED_FIELD_ITEMDATE_DESC="Show the publication date of individual RSS Items."
MOD_FEED_FIELD_ITEMDATE_LABEL="Publication Date"
MOD_FEED_FIELD_ITEMDESCRIPTION_DESC="Show the description or intro text of individual RSS items."
MOD_FEED_FIELD_ITEMDESCRIPTION_LABEL="Item Description"
MOD_FEED_FIELD_ITEMS_DESC="Enter number of RSS items to display."
Expand Down
24 changes: 24 additions & 0 deletions modules/mod_feed/mod_feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@
<option value="0">JNO</option>
</field>

<field
name="rssdate"
type="radio"
label="MOD_FEED_FIELD_DATE_LABEL"
description="MOD_FEED_FIELD_DATE_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>

<field
name="rssimage"
type="radio"
Expand Down Expand Up @@ -101,6 +113,18 @@
<option value="0">JNO</option>
</field>

<field
name="rssitemdate"
type="radio"
label="MOD_FEED_FIELD_ITEMDATE_LABEL"
description="MOD_FEED_FIELD_ITEMDATE_DESC"
class="btn-group btn-group-yesno"
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>

<field
name="word_count"
type="text"
Expand Down
12 changes: 11 additions & 1 deletion modules/mod_feed/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
</h2>
<?php
}
// Feed date
if ($params->get('rssdate', 1)) : ?>
<h3>
<?php echo JHtml::_('date', $feed->publishedDate, JText::_('DATE_FORMAT_LC3')); ?>
</h3>
<?php endif;
// Feed description
if ($params->get('rssdesc', 1))
{
Expand Down Expand Up @@ -103,7 +109,11 @@
<?php else : ?>
<span class="feed-link"><?php echo $title; ?></span>
<?php endif; ?>

<?php if ($params->get('rssitemdate')) : ?>
<div class="feed-item-date">
<?php echo JHtml::_('date', $feed[$i]->publishedDate, JText::_('DATE_FORMAT_LC3')); ?>
</div>
<?php endif; ?>
<?php if (!empty($text) && $params->get('rssitemdesc')) : ?>
<div class="feed-item-description">
<?php
Expand Down

0 comments on commit cf9c6c6

Please sign in to comment.