How to set a specific 404 page

Rate this topic: Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.Evaluations: 2, 3.50 on the average.3.50 out of 6 based on 2 vote(s)
GK User
Mon Jan 05, 2015 2:02 pm
Reply with quote
Report this post
Hi,
In my previous template I used custom 404 page. This one: index.php?option=com_content&view=article&layout=edit&id=100. How could I use this page with your News 2 template. I am using Joomla 3 and K2 .
User avatar
Expert Boarder

GK User
Tue Jan 06, 2015 12:28 pm
Reply with quote
Report this post
With gavick templates there is a specific file:
/news2/templates/gk_news2/error.php
which renders 404 page.
User avatar
Moderator

GK User
Tue Jan 06, 2015 3:02 pm
Reply with quote
Report this post
Thank you, but where in this code should I put my custom 404 page?
User avatar
Expert Boarder

GK User
Fri Jan 09, 2015 4:27 pm
Reply with quote
Report this post
I need an answer to this, please!
User avatar
Expert Boarder

GK User
Sat Jan 10, 2015 9:52 am
Reply with quote
Report this post
You need to modify this file - its a php/html file with quite easy structure containing entire site (headers, body etc).
I don't know how you want to modify it.
User avatar
Moderator

GK User
Sat Jan 10, 2015 5:40 pm
Reply with quote
Report this post
I created specific page to be my 404 page. But I don`t know how to replace the default template 404 page with my custom one. In the previous templates I used there was an option to put the admin link to the page I created - index.php?option=com_content&view=article&layout=edit&id=100 and everything worked just fine. Like here: https://docs.joomla.org/Creating_a_Cust ... Error_Page. And in your template I don`t know how to do it.
User avatar
Expert Boarder

GK User
Sun Jan 11, 2015 11:26 am
Reply with quote
Report this post
You need to copy html structure from your custom page to that file.
Could you please post an url to your site to this custom 404 one? Ill try to provide you with information what you need to copy.
User avatar
Moderator

GK User
Sun Jan 11, 2015 11:33 am
Reply with quote
Report this post
Ok, I just got a great tip from one of our mods... Forget everything... Simply edit error.php file and replace its content with:
Code: Select all
<?php
header( 'Location: http://www.redirected.com/' );
exit;
?>

where 'http://www.redirected.com/' is a link to a custom content that should act as new 404 page.
User avatar
Moderator

GK User
Sun Jan 11, 2015 5:10 pm
Reply with quote
Report this post
Should I replace all of the error.php content only with this code? Or add this somewhere?
User avatar
Expert Boarder

GK User
Tue Jan 13, 2015 5:56 pm
Reply with quote
Report this post
It should work doing it one of two ways:
1. Replace entire file with only this code
2. Appending this code to the file (at it's top) and leaving all the rest - it should execute this code and stop right after not executing anything else.
User avatar
Moderator

GK User
Wed Jan 14, 2015 9:01 am
Reply with quote
Report this post
OK - I put your code in the beggining of error.php and replaced the link like this:
<?php
header( 'Location: index.php?option=com_content&view=article&layout=edit&id=100' );
exit;
?>
But now it gives me the following error: http://www.zdravduh.com/index.php/404
User avatar
Expert Boarder

GK User
Wed Jan 14, 2015 5:31 pm
Reply with quote
Report this post
Please copy entire error.php content and paste here between [ code ] and [/ code ] (without spaces) tags.
User avatar
Moderator

GK User
Thu Jan 15, 2015 8:46 am
Reply with quote
Report this post
Code: Select all
<?php

/**
 *
 * Error view
 *
 * @version             1.0.0
 * @package             Gavern Framework
 * @copyright         Copyright (C) 2010 - 2011 GavickPro. All rights reserved.
 *               
 */

// No direct access.
<?php
header( 'Location: index.php?option=com_content&view=article&layout=edit&id=100' );
exit;
?>

defined('_JEXEC') or die;

jimport('joomla.factory');
// get the URI instance
$uri = JURI::getInstance();
// get the template params
$templateParams = JFactory::getApplication()->getTemplate(true)->params;

if($templateParams->get('webmaster_contact_type') != 'none') {
     // get the webmaster e-mail value
     $webmaster_contact = $templateParams->get('webmaster_contact', '');
     if($templateParams->get('webmaster_contact_type') == 'email') {
          // e-mail cloak
          $searchEmail = '([\w\.\-]+\@(?:[a-z0-9\.\-]+\.)+(?:[a-z0-9\-]{2,4}))';
          $searchText = '([\x20-\x7f][^<>]+)';
          $pattern = '~(?:<a [\w "\'=\@\.\-]*href\s*=\s*"mailto:' . $searchEmail . '"[\w "\'=\@\.\-]*)>' . $searchText . '</a>~i';   
          preg_match($pattern, '<a href="mailto:'.$webmaster_contact.'">'.JText::_('TPL_GK_LANG_CONTACT_WEBMASTER').'</a>', $regs, PREG_OFFSET_CAPTURE);
          $replacement = JHtml::_('email.cloak', $regs[1][0], 1, $regs[2][0], 0);
          $webmaster_contact_email = substr_replace($webmaster_contact, $replacement, $regs[0][1], strlen($regs[0][0]));
     }
}

// get necessary template parameters
$templateParams = JFactory::getApplication()->getTemplate(true)->params;
$pageName = JFactory::getDocument()->getTitle();

// get logo configuration
$logo_type = $templateParams->get('logo_type');
$logo_image = $templateParams->get('logo_image');
$template_style = $templateParams->get('template_color');

if(($logo_image == '') || ($templateParams->get('logo_type') == 'css')) {
     $logo_image = JURI::base() . '../images/logo.png';
} else {
     $logo_image = JURI::base() . $logo_image;
}

$logo_text = $templateParams->get('logo_text', '');
$logo_slogan = $templateParams->get('logo_slogan', '');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<title><?php echo $this->error->getCode(); ?>-<?php echo $this->title; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2.0">
<link href='http://fonts.googleapis.com/css?family=Bitter:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="<?php echo JURI::base(); ?>templates/<?php echo $this->template; ?>/css/system/error.style<?php echo $template_style; ?>.css" type="text/css" />
<?php if($templateParams->get('css_override')) : ?>
<link rel="stylesheet" href="<?php echo JURI::base(); ?>templates/<?php echo $this->template; ?>/css/override.css" type="text/css" />
<?php endif; ?>
</head>
<body>
<div id="gkPage">
      <div id="gkPageTop">
         <?php if ($logo_type !=='none'): ?>
            <?php if($logo_type == 'css') : ?>
            <a href="./" id="gkLogo" class="cssLogo"></a>
            <?php elseif($logo_type =='text') : ?>
            <a href="./" id="gkLogo" class="text"> <span><?php echo preg_replace('/__(.*?)__/i', '<sup>${1}</sup>', $logo_text); ?></span> <small class="gkLogoSlogan"><?php echo $logo_slogan; ?></small> </a>
            <?php elseif($logo_type =='image') : ?>
               <a href="./" id="gkLogo"> <img src="<?php echo $logo_image; ?>" alt="<?php echo $pageName; ?>" /></a>
            <?php endif; ?>
         <?php endif; ?>
      </div>
      <div id="gkPageWrap">
            <div id="frame">
                  <div id="errorDescription">
                        <?php if($this->error->getCode() == 403 || $this->error->getCode() == 404) : ?>
                           <h2><span><?php echo $this->error->getCode(); ?></span><?php echo JText::_('TPL_GK_LANG_ERROR_INFO'); ?> </h2>
                        <?php else : ?>
                           <h2><span><?php echo $this->error->getCode(); ?></span><?php echo $this->error->getMessage(); ?> </h2>
                        <?php endif; ?>
                        <h3><?php echo JText::_('TPL_GK_LANG_ERROR_DESC'); ?></h3>
                  </div>
            </div>
            <div id="errorboxbody"> <a href="<?php echo JURI::base(); ?>" title="<?php echo JText::_('JERROR_LAYOUT_GO_TO_THE_HOME_PAGE'); ?>"><?php echo JText::_('JERROR_LAYOUT_HOME_PAGE'); ?></a> |
                  <?php if($templateParams->get('webmaster_contact_type') == 'email') :
                          echo $webmaster_contact_email;
                     ?>
                  <?php elseif($templateParams->get('webmaster_contact_type') == 'url') : ?>
                  <a href="<?php echo $webmaster_contact; ?>">
                  <?php  echo JText::_('TPL_GK_LANG_CONTACT_WEBMASTER'); ?>
                  </a>
                  <?php endif; ?>
            </div>
      </div>
</div>
</body>
</html>
User avatar
Expert Boarder

GK User
Fri Jan 16, 2015 5:52 pm
Reply with quote
Report this post
You haven't added the code at the beginning but in the middle of the file.
To make it work where it is currently change:
Code: Select all
// No direct access.
<?php
header( 'Location: index.php?option=com_content&view=article&layout=edit&id=100' );
exit;
?>

defined('_JEXEC') or die;

to:
Code: Select all
// No direct access.
header( 'Location: index.php?option=com_content&view=article&layout=edit&id=100' );
exit;

defined('_JEXEC') or die;
User avatar
Moderator

GK User
Sat Jan 17, 2015 11:35 am
Reply with quote
Report this post
Ok, thank you! It works now. I haven`t noticed the opening tag <?php in the beggining before the text. Thank you so much :)
User avatar
Expert Boarder

GK User
Mon Jan 19, 2015 7:45 am
Reply with quote
Report this post
Is there anything else I can help you with regarding this topic?
User avatar
Moderator

GK User
Mon Jan 19, 2015 9:28 am
Reply with quote
Report this post
Yes, now when you ask i remember something strange. Usually the 404 page should appear when you write the domain and non existing symbols after that. But in my case it doesn`t as you may see from this link: http://www.zdravduh.com/kkkk. It appears only when I write: http://www.zdravduh.com/index.php/kkkk. How to make it appear when index.php is missing?
User avatar
Expert Boarder

GK User
Tue Jan 20, 2015 12:21 pm
Reply with quote
Report this post
It is general Joomla question.
Please check this url:
http://www.inmotionhosting.com/support/ ... -index-php
User avatar
Moderator


cron