MyBB Community Forums

Full Version: IF mobile Read More
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. With the plugin template conditionals we can use IF commands. I'm using bootstrap at my forum, and want to make a "read more/ or collaps" option to xs (mobile phones) in potal.php.

Is there a way of coding the portal to show lets say 100 characters or string, then add a read more button or a collaps button, but for bigger screens show the whole content?

OR is it possible to use the plugin Portal News Preview and duplicate the plugin (change name for one of them) and let one of the plugin work at screens bigger then xs, and the other plugin at only xs devices?

Hope someone will take the time to help me
Responsive frameworks have built in functions to deal with this. Both Bootstrap and W3, which is less dependent on javascript and easier to learn. W3 eg. has the classes hide-small, hide-medium, hide-large to help achieve what you trying to do.
That is not what I mean. I do not want to hide it that way, just want it to show the content when pressing read more.
Using hide code will hide the content, and will not be able to show the content pressing a button.
(2016-06-10, 08:40 AM)BaggerHD Wrote: [ -> ]That is not what I mean. I do not want to hide it that way, just want it to show the content when pressing read more.
Using hide code will hide the content, and will not be able to show the content pressing a button.

Not true. You can use any icon to trigger the collapse to show the content you're hiding.
OK, so should I then use a IF commando inside 2 different <div>, one for IF xs, and one for the rest, and inside the two different div's use a max height before breakpoint for the collapse? Or is there a different way to do it?
i would not use php conditionals on this at all. Why not make the whole description collapse on the small screen with a trigger button. If you insist on displaying the first say 100 characters, then you are going to need to change the core code. Eg I can think of is in portal.php where the latest thread subject get's truncated to 25 characters.

		if(my_strlen($thread['subject']) > 25)
		{
			$thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
		}
There happens to be an addon for this, no need to reinvent the wheel:

http://community.mybb.com/mods.php?action=view&pid=373