MyBB Community Forums

Full Version: Portal News Preview: add Read More button to portal News
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I had a forum with Mybb and the portal has ever made me boring because the news are displayed in them full height, so scrolling the page to the bottom was a pain.

Initially i develop a plugin to cut the news and add a readmore button after a string, then i change board and forgot about this.

On my new forum board there isn't a portal, so i had install a plugin to add the portal page, but i had the same problem, how to cut the news?

Well firstly i included the functionality of my first plugin on the portal plugin, then i realised that i could did several improvement.

After i did that improvements i decided to take my old MyBB plugin, update it then release it, because i know that several MyBB admin want this plugin.



[Image: preview.gif]




TAKEN FROM README.txt

Quote:======================================================
Copyright Notice
======================================================

This plugin is written by me, bodega, and i hope that everything is fine. I tested it several time over a new installation of MyBB 1.8.6 and everything is good.

You can find more web development related content on my GitHub profile: erbodega.github.io

If you are a dev and want impove my plugin feel free to send me a pull request, if you code is good i will accept it.

Don't remove the copyright notice from this file (ReadMe.txt) and don't change the copyright information inside the plugin, respect my work.



======================================================
Portal News Preview 1.0 by bodega - ps4mod.net - erbodega.github.io
======================================================


This plugin cut the news in the portal adding a Read More button, just like WordPress do. You can choose three way to cut your news, just choose what you prefer.

Before starting i suggest you to edit the templates of your portal in order to remove the avatar column, having a more blog-style portal that is really better.

The three way to cut the news are:
  • After the first image (wordpress like)
  • After a string
  • After N characters (It may show broken bbcode if the setted up number is in the middle of a bbcode tag, i know this and had already a solution, i just need the time to update the plugin)



======================================================
Installation
======================================================
The installation process is very simply, just:
  1. Upload the plugin file "portal_news_preview.php" to yourMyBBforum.com/inc/plugins
  2. Activate and Install the plugin via the Admin Control Panel -> Plugins
  3. Eventually you may want to change the default configuration. To access them jus go to Admin CP -> Setting -> Portal Settings: you will find the configuration at the bottom.

If you want to unistall this plugin just
  1. Go to Admin Control Panel -> Plugins
  2. Click on Deactivate
  3. Click on Uninstall
  4. Remove the php file via ftp


======================================================
Change Read More button style
======================================================

This plugin will install a new css in the default theme, so if you want to edit the background color etc. just go to Admin CP -> Template & Style -> Themes then choose your theme.

You should see a new css file called readmore.css that is Inherited from MyBB Master Style, just edit it and save changes. Any changes you make will break the inheritance, and the stylesheet will be copied to your theme.




======================================================
Test the functionality          
======================================================

If you want to test the plugin functionality, post this thread in one of your forum where the threads appear in the portal as a news:

Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. Testing thread. 

[img]http://community.mybb.com/images/logo.png[/img]

Text before the cut string that is: cut_me_here

This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal. This should not be visible on portal.



Download Mods site:
http://community.mybb.com/mods.php?action=view&pid=643


Expect a new awesome release in the coming days.

Cheers,
erBodega
Added mods site link and approved.
Hi,

Really good plugin, thank you !

How to only show first [img] [/img] ?

Nothing before, Nothing After.

if($mybb->settings['whichway'] == 1) {
            $announcement['message'] = substr($announcement['message'], 0, strpos($announcement['message'], '[/img]', strpos($announcement['message'], '[img', 0)) + 6);
            $announcement['link'] = "<strong><a class=\"readmore\" target=\"_blank\" href=".$mybb->settings['bburl']."/".$announcement['threadlink'].">".$mybb->settings['readmoremessage']."</a></strong>";
        }
changing admin directory is common thing to do, so maybe you should considering it, when requiring functions_themes.php


require_once(MYBB_ROOT."admin/inc/functions_themes.php");

this plugin will work with external (URL) IMG, but won't work with Image from attachment. Hope you'll update it.