Any suggestions for turning on the visual editor for as the default for creating a page? It still defaults to the old editor.
Still experimenting. Great work everyone.
Any suggestions for turning on the visual editor for as the default for creating a page? It still defaults to the old editor.
Still experimenting. Great work everyone.
If you have VisualEditor switched on, you should get "Create" and "Create source". The first takes you into VisualEditor, the second to the wikitext editor. Does this not show up for you?
Almost, the visual editor is available as an option, and works when I click on the tab. However it defaults to the edit source.
Here's my localsettings:
require_once("$IP/extensions/VisualEditor/VisualEditor.php"); ## Visual Editor Settings: // Create VisualEditor namespace define( 'NS_VISUALEDITOR', 2500 ); define( 'NS_VISUALEDITOR_TALK', 2501 ); $wgExtraNamespaces[NS_VISUALEDITOR] = 'VisualEditor'; $wgExtraNamespaces[NS_VISUALEDITOR_TALK] = 'VisualEditor_talk'; // Allow using VisualEditor in the main namespace only (default) $wgVisualEditorNamespaces ['*']; // $wgVisualEditorNamespaces = array( NS_MAIN, NS_TALK, NS_USER, NS_USER_TALK ); // Restrict VisualEditor to the VisualEditor namespace //$wgVisualEditorNamespaces = array(); //$wgVisualEditorNamespaces[] = NS_VISUALEDITOR; // Enable by default for everybody $wgDefaultUserOptions['visualeditor-enable'] = 1; // Don't allow users to disable it $wgHiddenPrefs[] = 'visualeditor-enable';
I have the same request. Creating pages through a link or through the search box always loads the markup editor, and you have to change to VE manually with the "create" tab. This behaviour is very confusing for my users. By the way, preloading a template also doesn't work with VE.
Hello, I also work on this issue. I developed a special page extension for creating an article. The user has to type the name of article, then after a search (checking if already exists) user select a template and click create. Behind "create" there's this link 'http://yourmedia.wiki/index.php?title=[ARTICLE_NAME]&veaction=edit&redlink=1'. So, the visual editor will start and the user can create content.
But the preloading of templates also doesn't work. With the standard eitor this was easy by using NewArticleTemplate extension. But the used hook 'EditPage::showEditForm:initial' doesn't work with VE. Can anyone help? Otherwise I implement an work-around (some 'Javascript magic').
If you have a workaround, that would be great. I have the same issue, and it would be enough if an extension just creates and saves a new page by copying the template, and the user then can click on "edit" to actually modify it. This would solve both problems (that VE isn't default, and it doesn't handle templates). Is it possible to copy a page using URL parameters?
I implement an extension for this issue. Actually, it's based on MediaWiki WriteAPI which is not a good solution because it makes it easy for automatic editing by bots. But it works. The user chooses a name and a template from a list and click create. In background AJAX is used to get MediaWiki text from choosen template and then creates the page by using the WriteAPI (where you give template text as a parameter). Finaly, the user is automatically forwarded to the new page with opened visual editor.
Is this extension available somewhere? Sounds useful and I'd like to test it.
I have implemented the following crude hack into the top of my index.php:
if($_GET['redlink']==1 && $_GET['action']=='edit') { header('Location: index.php?title='.$_GET['title'].'&veaction=edit&redlink=1'); die(); }
Hope this helps someone.
Hi - is this suppose to be placed in the index.php of the wiki folder? I did that and got all kinds of errors.
Nevermind I figured out how to do it. You can't simply use that code, you have to modify it to first check if the page even has those tags in the url. this works
if(isset($_GET["redlink"]) && isset($_GET["action"])){ $clicked_edit_link = ($_GET["redlink"]); $action_doing_now = ($_GET["action"]);
if($clicked_edit_link==1 && $action_doing_now=='edit') { header('Location: index.php?title='.$_GET['title'].'&veaction=edit&redlink=1'); die(); }}
All you need is to modify (noarticletext) message at Special:Allmessages - just replace action=edit by veaction=edit
Thanks! That works great for creating pages based on what you type in the URL (ie: www.example.com/wiki/newpage123). But it does not work if you type "newpage123" in the search box. If you want to be able to create pages from the search box using Visual Editor, you would also have to edit the special message MediaWiki:Searchmenu-new
Here is what I came up with for that:
<strong>[{{fullurl:$1|veaction=edit}} Create the page "$1"] on this wiki!</strong>
@Vedmaka & @Potrod's suggestions worked well for me. I recommend this method.
@Vedmaka@Potrod any idea how to also make VisualEditor the default when clicking on a red link to create a new article?
@Vedmaka's tip and the code above worked for me and seems to cover all bases (page creation via a redlink, search or URL). The code above works fine when placed in the LocalSettings.php (instead of index) but you need to check for the existence of all $_GET parameters with isset($_GET['var'])
. Here is the final result:
# A hack that redirects users to the visual editor when clicking a redlink rather that to the wikicode editor. if(isset($_GET['redlink']) && isset($_GET['action']) && isset($_GET['title']) && $_GET['redlink'] == 1 && $_GET['action']=='edit') { header('Location: index.php?title='.$_GET['title'].'&veaction=edit&redlink=1'); die(); }
Note that this is now supported in VisualEditor-MediaWiki master (as will come out for compatibility with MW 1.27.0).
@Ianmelchior Maybe a little late to the party. I am using Mediawiki 1.27.1 stable and to set visual editor as default for redlink I write a hook on LinkBegin. Hope it helps someone.
public static function onLinkBegin( $dummy, $target, &$html, &$customAttribs,
&$query, &$options, &$ret ) {
if ( in_array( 'broken', $options, true ) && empty( $query['action'] )
&& $target->getNamespace() !== NS_SPECIAL ) {
$ret = Html::rawElement ('a', ['href' => $target->getFullURL('veaction=edit&redlink=1'), 'class' => 'new'], $target->getPrefixedDBKey());
return false;
}
return true;
}
Great idea @Baongoc124! But your code as is does not quite work as it needs to be hooked to the event ($wgHooks['LinkBegin'][] = 'onLinkBegin';
) and would not display the correct link text. Here is an improved and simplified version:
# A hack that redirects users to the visual editor when clicking a redlink rather that to the wikicode editor. function onLinkBegin( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) { if ( in_array( 'broken', $options, true ) && empty( $query['action'] ) && $target->getNamespace() !== NS_SPECIAL ) { $query['veaction'] = 'edit'; $query['action'] = 'view'; // Important! Otherwise MediaWiki will override veaction. $query['redlink'] = '1'; } return true; } $wgHooks['LinkBegin'][] = 'onLinkBegin'; // WARNING! Will be superseded by HtmlPageLinkRendererBegin in MediaWiki 1.28.
Note: to cover all bases, you still need to modify the noarticletext message as @Vedmaka suggested.
I have done this job with a little java script placed in page MediaWiki:Common.js
if ( wgArticleId === 0 && wgAction === 'edit' ) { window.location = 'index.php?title=' + wgPageName + '&veaction=edit&redlink=1'; }
It works for me. Hope it helps!
Based on @Tinss answer, here is a hook using HtmlPageLinkRendererBegin that can be added to LocalSettings.php
:
# Default to VisualEditor for red links class MyHooks { public static function onHtmlPageLinkRendererBegin($linkRenderer, $target, &$text, &$extraAttribs, &$query, &$ret) { $title = Title::newFromLinkTarget($target); $isKnown = $title->isKnown(); if (!$isKnown) { $query['veaction'] = 'edit'; $query['action'] = 'view'; // prevent MediaWiki from overriding veaction } } } $wgHooks['HtmlPageLinkRendererBegin'][] = 'MyHooks::onHtmlPageLinkRendererBegin';
Excellent work guys! This thread solved all my redlink problems XD Here is a shortened version of the snippet for those like me who don't like any fat in their code.
$wgHooks['HtmlPageLinkRendererBegin'][] = function ( $linkRenderer, $target, &$text, &$extraAttribs, &$query, &$ret ) { $title = Title::newFromLinkTarget( $target ); if ( !$title->isKnown() ) { $query['veaction'] = 'edit'; $query['action'] = 'view'; // Prevent MediaWiki from overriding veaction } };
Thanks to @Beatlicker from the post Enable All Name space see this --> Topic:Spky5rat787g67fj
Add blow lines to your LocalSettings.php page
$wgVisualEditorNamespaces = array_merge( $wgContentNamespaces, array( NS_USER, NS_CATEGORY ) );
$wgVisualEditorAvailableNamespaces = [
NS_MAIN => true,
NS_USER => true,
NS_HELP => true,
"_merge_strategy" => "array_plus"
];
If you need other standard namespace see Help:Namespaces to added standard that enable VisualEditor all the pages. Hope this Helps.
This did not work, is there more to the instructions?@Aravind2905
What are you trying to achieve? If it's enabling the Visual Editor for the create page, put Sophivorus' code at the bottom of LocalSettings.php.