Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve word count bug in mod_feed + some code review #8230

Closed
wants to merge 4 commits into from
Closed

Solve word count bug in mod_feed + some code review #8230

wants to merge 4 commits into from

Conversation

n9iels
Copy link
Contributor

@n9iels n9iels commented Nov 1, 2015

About this PR

This PR solves a bug with the word count parameter of mod_feed. If you load a feed with HTML tags (for example: http://community.joomla.org/blogs/community.feed?type=rss) and set the word count to 20 there are way less than 20 words visible. The two things that cause this problem:

  • JHtml::_('string.truncate') counts the characters, not the words of the string
  • HTML tags like <a href="http://link.nl"> are counted too

This PR change the text of the parameter to Character count and I also adds strip_tags() for the character count.

Other changes in this PR are code style and some change to make the code more readably and logic.

Test instructions

  1. Make a mod_feed module and use http://community.joomla.org/blogs/community.feed?type=rss as Feed URL, set the RTL Feed paramter on "No" and all other parameters on "Yes" for now
  2. Set the "Word count" parameter on 20, and confirm the feed displays less than 20 words on the front-end
  3. Apply the patch, and confirm the parameter is now called "Character limit" and the amount of characters is better now (Maybe still not 20 characters, because the function don't cut words in half)
  4. Confirm all parameters are working like they use to do
  5. Install an RTL language (Persion for example), and test the "RTL Feed" parameter for this language. If "RTL Feed" is set to no, even on RTL languages the feed must be displayed LTR

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-staging labels Nov 1, 2015
}

$feed = ModFeedHelper::getFeed($params);
$feed = ModFeedHelper::getFeed($params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can you use spaces to align here! Thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed 👍

@Ruchiranga
Copy link
Contributor

I have tested this item 🔴 unsuccessfully on 61f6253

### Tested successfully

Tested unsuccessfully

@joomla-cms-bot
Copy link

This PR has received new commits.

CC: @Ruchiranga


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8230.

@joomla-cms-bot
Copy link

This PR has received new commits.

CC: @Ruchiranga


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8230.

@n9iels
Copy link
Contributor Author

n9iels commented Mar 15, 2016

@Ruchiranga Thanks for testing! Yes you're right, the RTL function wasn't working, I used a wrong variable. I also changed the label of the parameter to Character limit, that is a better label indeed.

Can you please test again, and confirm the problems are solved?

@Ruchiranga
Copy link
Contributor

I have tested this item ✅ successfully on 607a440

* The amount of characters shown has become better. See
Before applying the patch and
After applying the patch.

@coolcat-creations
Copy link
Contributor

I´m not sure if this breaks something on existing sites because even if the wordcount didn´t work right before
i don´t know if we can just change it to character limit?

Isn´t it better to fix the wordcount instead?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8230.

@brianteeman
Copy link
Contributor

Changing from word count to character count will break peoples sites. Imagine I have it set to 10

before

my news feed of approximately ten words excepting html bug

after

my news fe

So with this change form word to character count it cannot be accepted.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8230.

@brianteeman
Copy link
Contributor

If you want to update the PR to retain the word count then this can be tested otherwise I am afraid it will have to be closed


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8230.

@brianteeman
Copy link
Contributor

Closed for the reason above


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8230.

@brianteeman brianteeman closed this May 8, 2016
@n9iels n9iels deleted the mod_feed branch September 25, 2016 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Language Change This is for Translators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants