Skip to content

Commit

Permalink
Added global option for home 404. If Fabrik is home page, and a URL i…
Browse files Browse the repository at this point in the history
…s not found, should Fabrik just go ahead and load the configured home link, or throw a 404.
  • Loading branch information
cheesegrits committed Jul 25, 2017
1 parent bcb891c commit 261c78a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions administrator/components/com_fabrik/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@
<option value="1">JYES</option>
</field>

<field name="fabrik_home_404"
class="radio btn-group"
type="radio"
default="0"
label="COM_FABRIK_FIELD_HOME_404_LABEL"
description="COM_FABRIK_FIELD_HOME_404_DESC">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

</fieldset>
<fieldset label="COM_FABRIK_LISTS" name="lists">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,8 @@ COM_FABRIK_DROPDOWN_JQUERY_CHOSEN_OPTIONS_LABEL="Enhanced Dropdowns options"
COM_FABRIK_DROPDOWN_JQUERY_CHOSEN_OPTIONS_DESC="Options for 'chosen' behaviour, in JSON notation, like {"_QQ_"no_results_text"_QQ_":"_QQ_"No matches!"_QQ_","_QQ_"search_contains"_QQ_":true}, as per https://harvesthq.github.io/chosen/options.html (except you need to quote the option names)."
COM_FABRIK_FIELD_ALLOW_USER_DEFINES_LABEL="Allow User Defines"
COM_FABRIK_FIELD_ALLOW_USER_DEFINES_DESC="ADVANCED - if enabled, the main Fabrik PHP definitions file can be overridden by copying ./plugins/system/com_fabrik/defines.php to user_defines.php in the same folder, and modifying it. DO NOT use this feature unless you know what you are doing!"
COM_FABRIK_FIELD_HOME_404_DESC="If the Home page is a Fabrik component link, and a URL is not found, should Fabrik return a 404, or show the configured home link. If you are worried about SEF duplication, set this to Yes, so a 404 will be returned. If you are more interested in the user experience, set it to No"
COM_FABRIK_FIELD_HOME_404_LABEL="Home 404"

COM_FABRIK_LABELS="Labels"
COM_FABRIK_LABELS_LABEL="Default action for creation of labels"
Expand Down
13 changes: 10 additions & 3 deletions components/com_fabrik/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// No direct access
defined('_JEXEC') or die('Restricted access');

use \Joomla\Utilities\ArrayHelper;
use Joomla\Utilities\ArrayHelper;

/**
* if using file extensions sef and htaccess :
Expand Down Expand Up @@ -304,8 +304,14 @@ function fabrikParseRoute($segments)
/*
* if a Fabrik view is home page, and this is a 404, no segments, but J! will still try and route com_fabrik
* So have a peek at the active menu, and break down the link
*
* 7/25/2017, made this behavior an option, as can cause SEF issues with duplicate pages
*/
if (!$viewFound)

$config = JComponentHelper::getParams('com_fabrik');
$home404 = $config->get('fabrik_home_404', '0') === '1';

if (!$home404 && !$viewFound)
{
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('JGLOBAL_RESOURCE_NOT_FOUND'));
Expand Down Expand Up @@ -357,7 +363,8 @@ function fabrikParseRoute($segments)

if (!$viewFound)
{
JError::raiseError(404, JText::_('JGLOBAL_RESOURCE_NOT_FOUND'));
//JError::raiseError(404, JText::_('JGLOBAL_RESOURCE_NOT_FOUND'));
throw new \Exception('JGLOBAL_RESOURCE_NOT_FOUND.', 404);
}

return $vars;
Expand Down

0 comments on commit 261c78a

Please sign in to comment.