GetSimple Support Forum
[SOLVED] - New page button, for pg not found - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Scripts & Components (http://get-simple.info/forums/forumdisplay.php?fid=11)
+--- Thread: [SOLVED] - New page button, for pg not found (/showthread.php?tid=7817)



[SOLVED] - New page button, for pg not found - jwzumwalt - 2016-01-06

Is there a way to have a 404 page not found, know what page was being attempted and have a button that offers to create a new page with that name?

Media Wiki does this, and I would like to do this, if it is possible.


RE: Need new page, for pg not found - DimaYakovlev - 2016-01-08

(2016-01-06, 00:13:25)jwzumwalt Wrote: Is there a way to have a 404 page not found, know what page was being attempted and have a button that offers to create a new page with that name?

Media Wiki does this, and I would like to do this, if it is possible.

There is no built in functionality for this, but you can create plugin.


RE: [NOT POSSIBLE] - New page button, for pg not found - DimaYakovlev - 2016-01-18

(2016-01-06, 00:13:25)jwzumwalt Wrote: Is there a way to have a 404 page not found, know what page was being attempted and have a button that offers to create a new page with that name?

Media Wiki does this, and I would like to do this, if it is possible.

Possible


RE: [NOT POSSIBLE] - New page button, for pg not found - DimaYakovlev - 2016-02-06

Since the problem is solved, it is possible that solution may be useful for others users.

1. Create new plugin with given code and activate it.
PHP Code:
<?php
/*
Plugin Name: New Page From 404
Description: Helps user to create a new page from 404 
Version: 0.1
Author: Dmitry Yakovlev
Author URI: http://dimayakovlev.ru
*/

$thisfile basename(__FILE__'.php');

# register plugin
register_plugin(
 
 $thisfile,
 
 'New Page From 404',
 
 '1.0',
 
 'Dmitry Yakovlev',
 
 'http://dimayakovlev.ru',
 
 'Helps user to create a new page from 404',
 
 '',
 
 ''
);

add_action('admin-pre-header''get_new_page_from_404_admin');

function 
get_new_page_from_404_admin() {
 
 global $url;
 
 if (basename($_SERVER['PHP_SELF']) == 'edit.php') {
 
   if (!$url && isset($_GET['newpagefrom404'])) {
 
     $url $_GET['newpagefrom404'];
 
   }
 
 }
}

function 
get_new_page_from_404_link($link_title) {
 
 global $id$url$GSADMIN;
 
 if ($url '404' && $id != '404' && is_logged_in()) {
 
   $url get_site_url(false) . $GSADMIN '/edit.php?newpagefrom404=' urlencode($id);
 
   echo '<a href="' $url '">' $link_title '</a>';
 
  


2. Place this code in template file which used for your website 404 page.
PHP Code:
if (function_exists('get_new_page_from_404_link')) {
 
 get_new_page_from_404_link('Create page');

Done!