Automatically refreshing the news feed?

Rishi B Posted in Component Development 6 years ago

I've noticed that if you leave a browser tab open on the OSSN newsfeed page, and someone else makes a post to the newsfeed, you'll have to manually refresh the page in order to see the new post. Has anyone thought about having this done in the background like on facebook? I used the HtmlSidebar component to add some javascript which reloads the page every 10 minutes, but I'm sure there's a cleaner solution.

Replies
us Michieal ~ Coder ~ Replied 3 years ago

I would seriously dislike a full page refresh; especially if I was commenting. One of the biggest complaints about facebook is it reordering and refreshing things on you, and then not being able to find where you were. And, if you're the type of person that types out long replies, a forced refresh (ESPECIALLY) with no warning will immediately anger you.
My suggestion - Nix that immediately. Instead, use java script to pop up a notice of new activity, and give the user the option to refresh.
-M.

gr Hala Halaa Replied 3 years ago

Hello Joey i add it , and i see my whole site refresh every 5 minutes.
maybe i add it in the wrong line ? any tips exactly in which line i should have it ?

German Michael Zülsdorff Replied 3 years ago

Hmm ... and do you think of adding some kind of alarm signal before that refresh will happen?
Or how would I know?

us Joey Champion Replied 3 years ago

A very simple solution...
My easy solution on the automatic page refreshing.
On your web server, you will find the newsfeed file, newsfeed.php in
your themes folder.
Here is the path.
/var/www/html/ossn/themes/YOURTHEME/plugins/default/theme/page/layout
(Remember, you are looking for the file newsfeed.php.
Edit the file with your favorite editor.
Insert the following code...

<meta http-equiv="refresh" content="300">

right above the line that reads...
div class="container-fluid".

Save the file. All done.
If you can't directly edit the file on your server, edit the theme locally on your pc.
Save your changes, zip it up and upload it to your site.
( I am assuming you know how to change the default theme/and install a new theme to your site). If not, well, I will explain more if necessary.
(300 = 5minutes).

in Balamurali Govindan Replied 3 years ago

3 years old discussion, not sure if things have changed. As mentioned by Arsalan, is this now the functionality of the standard build or do we still need to add this script to make it work?

Please advise. Thank You.

us Rishi B Replied 6 years ago

I already explained the solution. All you need to do is add javascript code to refresh the page ay a given interval such as this: https://stackoverflow.com/questions/19807665/auto-refresh-for-every-5-mins

Just put the script code into the HtmlSidebar component.

German Roland Bachner Replied 6 years ago

I would appreciate a solution too ;-)

us Rishi B Replied 6 years ago

Use either of the components suggested, HtmlSidebar or Homelancer CSS/JS and you can put it anywhere, just fill in the text area for either of them. It is "preferred" to put the JS code in the head area, though not required.

us Helen Lubar Replied 6 years ago

Where exactly does one place the java script. In the head of which page.
thanks

Indonesian Arsalan Shah Replied 6 years ago

To refresh the page the javascript is required, you did right by creating js and reloading page every 10 minutes (or soon), the javascript can be placed anywhere in document, but its suggested to place in head.

I am thinking to make it similar to other social media but will require time before i come up with the solution.