e107 Core Code: e107 Addons

Images
Images
Images
Images
e107 Core Code: e107 Addons

e_frontpage.php

To add your plugin page to Frontpage options:

58f9d49838a3

You should know already what is Frontpage and how to use it.

8b6c1bed6789

Create file e_frontpage.php in your plugin folder (see _blank plugin for example).

Bellow is real example from content plugin:

class name = plugin name "_frontpage";

Note: with new plugin you should use new way how to load language strings.

if (!defined('e107_INIT')) { exit; }

include_lan(e_PLUGIN.'content/languages/'.e_LANGUAGE.'/lan_content_frontpage.php');

class content_frontpage // include plugin-folder in the name.<br />
{
	// simple
	function config()
	{
	  $frontPage = array();
		$frontPage['title'] = CONT_FP_3;
		$frontPage['page'] = 'e107_plugins/content/content.php';		
		return $frontPage;
	}
	
}


This is easy and you can find examples in other plugins too. Just look for e_frontpage.php file.

B4102e5626ac

But the content plugin separates content to sections and you maybe want to have the possibility to set different sections for different userclasses.

class content_frontpage
{
	function config()
	{
		$frontPage = array();
		$frontPage['title'] = CONT_FP_3;
		$frontPage['page'][0] = array(
			'page' => 'e107_plugins/content/content.php',
			'title' => CONT_FP_2
		);
		if ($maincat = e107::getDb()->retrieve("pcontent", "content_id, content_heading", 
		" WHERE content_parent='0'", true))
		{
			$i = 1;
			foreach($maincat as $row)
			{
				$row['url_content_id'] = $row['content_id'];
				$frontPage['page'][$i] = array(
					'page' => $PLUGINS_DIRECTORY . 'content/content.php?recent.' . $row['content_id'],
					'title' => CONT_FP_1 . ': ' . $row['content_heading']
				);
				  $i;                                                                            
				
				if ($subpages = e107::getDb()->retrieve("pcontent", "content_id, content_heading", 
				" WHERE LEFT(content_parent,1) = '" . $row['content_id'] . "' ORDER BY content_heading", TRUE))
				{
					foreach($subpages as $row2)
					{
						$frontPage['page'][$i] = array(<br />
							'page' => 'e107_plugins/content/content.php?content.' . $row2['content_id'],
							'title' =>  ' - ' . $row['content_heading'] . ' - ' . $row2['content_heading']
						);
						  $i;
					}
				}
			}
		}

		return $frontPage;
	}
}


002822f8dee9


Known issues with Frontpage:

Fatal error: require_once(): Failed opening required '../../class2.php'


This:

require_once('../../class2.php');


Need to be changed to:

if(!defined('e107_INIT')) 
{ 
	require_once('../../class2.php'); 
}

Comparing with version 1.0.4:


- old ways with arrays are not supported, you need to rewrite this file to new standards
- there is a change in behavior in version 2 - one plugin can have just one line in Frontpage. This is not possible now (or yet):

664b94dda82a



Notes:

* For layout/look is FRONTPAGE layout applied (if it's used), not defined layout for original URL.
* you can set different frontpage for any userclass,
* you can set after login page this way too different for userclasses
* you can extend frontpage of core plugins this way too - just create your own plugin and create options with core tables (for example download categories)

10 Years

GLORIOUS YEARS

100%

SATISFACTION RATE

20+

e107 THEMES

10+

e107 PLUGINS

Images