Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
Recent Tutorials
Top posting users this month
Top Achievers
Who is online?
In total there are 54 users online :: 0 Registered, 0 Hidden and 54 Guests :: 1 Bot
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
"Edit this page" feature
Page 1 of 1 • Share
Just a plugin that displays a link next to the title so that admins can quickly edit pages, forums, categories, and groups.
Administration Panel > Modules > HTML & Javascript > Javascript codes management
Title: "Edit this page" feature
Placement: In all the pages
Code:
lang - Language data
If you'd like, you can change the respective strings to your desired language and that's what will appear next to the titles.
The code above shows the selectors for the title that the "Edit this [...]" link will be appended to. If there is no element that matches them, then there won't be a shortcut link to the page/forum/category/group.
Basically, I'm saying that if you want to be able to edit an html page, then you need to ensure that you have an element somewhere on that page that matches the selector for your respective forum version.
If the code doesn't work for you, then please leave a reply below and I'll modify the code so that it will work on your forum.
Installation
Administration Panel > Modules > HTML & Javascript > Javascript codes management
Title: "Edit this page" feature
Placement: In all the pages
Code:
- Code:
(function() {
'edit this page';
'by ace 1';
window.fa_special_edits = {
lang: {
edit: 'Edit this',
page: 'page',
forum: 'forum',
category: 'category',
group: 'group'
},
title: [
// phpbb3 && fa edge
'h1.page-title',
// punbb
'.main-head h2',
// invision
'[class="borderwrap"] .maintitle :header'
],
text: function(type) {
return fa_special_edits.lang.edit + ' ' + (type == 1 ? fa_special_edits.lang.page : type == 2 ? fa_special_edits.lang.forum : type == 3 ? fa_special_edits.lang.category : fa_special_edits.lang.group)
},
style: '<style type="text/css" name="page-title-link">.edit-link{font-size:0.6em;margin-left:5px;vertical-align:top}</style>',
version: function() {
return $('#wrap, #fa_edge')[0] ? 0 : $('div.pun')[0] ? 1 : document.getElementById('ipbwrapper') ? 2 : -1
},
admin: 'a[href^="/admin/index.forum"]',
pageIDs: {
html: location.href.replace(/.*\/h(\d+)-.*/, '$1'),
forums: location.href.replace(/.*\/f(\d+).*/, '$1'),
cats: location.href.replace(/.*\/c(\d+)-.*/, '$1'),
groups: location.href.replace(/.*\/g(\d+)-.*/, '$1')
},
editID: function(pageID, type) {
var edit_link;
switch (type) {
case 1:
edit_link = '/admin/index.forum?part=modules&sub=html&mode=go_edit&page=' + pageID + '&editor=html&extended_admin=1';
break;
case 2:
edit_link = '/admin/index.forum?part=general&sub=general&mode=edit&extended_admin=1&fid=f' + pageID;
break;
case 3:
edit_link = '/admin/index.forum?part=general&sub=general&mode=edit&extended_admin=1&fid=c' + pageID;
break;
case 4:
edit_link = '/admin/index.forum?part=users_groups&sub=groups&g=' + pageID + '&mode=editgroup&extended_admin=1';
break;
}
return edit_link;
},
init: function() {
console.log(fa_special_edits.version());
if (fa_special_edits.version() < 0) {
console.warn('This forum does not support the edit page plugin. Visit the following URL for help:');
console.log('http://fmdesign.forumotion.com/t1406-edit-this-page-feature');
return;
}
fa_special_edits.title = fa_special_edits.title[fa_special_edits.version()];
var title = $(fa_special_edits.title).first(),
admin_link = $(fa_special_edits.admin),
adminID;
if (!admin_link[0]) return;
adminID = admin_link[0].href.replace(/.*part=admin(.*)/, '$1');
switch (true) {
// HTML Pages
case /\/h\d+-/.test(location.href):
if (!title[0]) return;
title.append('<a href="' + fa_special_edits.editID(fa_special_edits.pageIDs.html, 1) + '" class="edit-link">[' + fa_special_edits.text(1) + ']</a>');
break;
// Forums
case /\/f\d+[p]?\d*-/.test(location.href):
if (!title[0]) return;
title.append('<a href="' + fa_special_edits.editID(fa_special_edits.pageIDs.forums, 2) + '" class="edit-link">[' + fa_special_edits.text(2) + ']</a>');
break;
// Categories
case /\/c\d+-/.test(location.href):
if (fa_special_edits.version == 0) {
var category_name = document.getElementsByTagName('title')[0].innerHTML;
if (!title[0]) title = $('<h1 class="page-title">' + category_name + '</h1>');
$('p.right.rightside + p').after(title);
}
if (!title) return;
title.append('<a href="' + fa_special_edits.editID(fa_special_edits.pageIDs.cats, 3) + '" class="edit-link">[' + fa_special_edits.text(3) + ']</a>');
break;
// Groups
case /\/g\d+-/.test(location.href):
if (!title[0]) return;
title.append('<a href="' + fa_special_edits.editID(fa_special_edits.pageIDs.groups, 4) + '" class="edit-link">[' + fa_special_edits.text(4) + ']</a>');
break;
}
if (!$('.edit-link')[0]) {
console.warn('An error occurred when appending the link [Edit Pages Plugin]\n\nVisit the thread on http://fmdesign.forumotion.com for assistance.');
return;
}
$('.edit-link')[0].href += adminID;
$('head').append(fa_special_edits.style);
}
};
/(?:\/h\d+-)|(?:\/f\d+[p]?\d*-)|(?:\/c\d+-)|(?:\/g\d+-)/.test(location.href) && $(function() {
fa_special_edits.init();
});
})();
- eval is evil [OLD]:
- Code:
window.fa_special_edits = {
lang: {
edit: 'Edit this',
page: 'page',
forum: 'forum',
category: 'category',
group: 'group'
},
text: function(type) {
return fa_special_edits.lang.edit + ' ' + (type == 1 ? fa_special_edits.lang.page : type == 2 ? fa_special_edits.lang.forum : type == 3 ? fa_special_edits.lang.category : fa_special_edits.lang.group)
},
style: '<style type="text/css" name="page-title-link">.page-title a:last-child{font-size:0.6em;margin-left:5px;vertical-align:top}</style>',
title: '$(\'h1.page-title\').first()',
admin: '$(\'a[href^="/admin/index.forum"]\')',
adminID: 'eval(fa_special_edits.admin)[0] ? eval(fa_special_edits.admin)[0].href.replace(/.*part=admin(.*)/, \'$1\') : null',
pageIDs: {
html: location.href.replace(/.*\/h(\d+)-.*/, '$1'),
forums: location.href.replace(/.*\/f(\d+).*/, '$1'),
cats: location.href.replace(/.*\/c(\d+)-.*/, '$1'),
groups: location.href.replace(/.*\/g(\d+)-.*/, '$1')
},
editID: function(pageID, type) {
var edit_link;
switch (type) {
case 1:
edit_link = '/admin/index.forum?part=modules&sub=html&mode=go_edit&page=' + pageID + '&editor=html&extended_admin=1';
break;
case 2:
edit_link = '/admin/index.forum?part=general&sub=general&mode=edit&extended_admin=1&fid=f' + pageID;
break;
case 3:
edit_link = '/admin/index.forum?part=general&sub=general&mode=edit&extended_admin=1&fid=c' + pageID;
break;
case 4:
edit_link = '/admin/index.forum?part=users_groups&sub=groups&g=' + pageID + '&mode=editgroup&extended_admin=1';
break;
}
return edit_link + eval(fa_special_edits.adminID);
}
};
// HTML Pages
/\/h\d+-/.test(location.href) && $(function() {
if (!eval(fa_special_edits.title)[0] || !eval(fa_special_edits.admin)[0]) return;
eval(fa_special_edits.title).append('<a href="' + fa_special_edits.editID(fa_special_edits.pageIDs.html, 1) + '">[' + fa_special_edits.text(1) + ']</a>');
$('head').append(fa_special_edits.style);
});
// Forums
/\/f\d+[p]?\d*-/.test(location.href) && $(function() {
if (!eval(fa_special_edits.title)[0] || !eval(fa_special_edits.admin)[0]) return;
eval(fa_special_edits.title).append('<a href="' + fa_special_edits.editID(fa_special_edits.pageIDs.forums, 2) + '">[' + fa_special_edits.text(2) + ']</a>');
$('head').append(fa_special_edits.style);
});
// Categories
/\/c\d+-/.test(location.href) && $(function() {
if (!eval(fa_special_edits.admin)[0]) return;
var category_name = $('title')[0].innerHTML;
if (!eval(fa_special_edits.title)[0]) $('p.right.rightside + p').after('<h1 class="page-title">' + category_name + '</h1>');
eval(fa_special_edits.title).append('<a href="' + fa_special_edits.editID(fa_special_edits.pageIDs.cats, 3) + '">[' + fa_special_edits.text(3) + ']</a>');
$('head').append(fa_special_edits.style);
});
// Groups
/\/g\d+-/.test(location.href) && $(function() {
if (!eval(fa_special_edits.title)[0] || !eval(fa_special_edits.admin)[0]) return;
eval(fa_special_edits.title).append('<a href="' + fa_special_edits.editID(fa_special_edits.pageIDs.groups, 4) + '">[' + fa_special_edits.text(4) + ']</a>');
$('head').append(fa_special_edits.style);
});
Modifications
lang - Language data
- Code:
lang: {
edit: 'Edit this',
page: 'page',
forum: 'forum',
category: 'category',
group: 'group'
},
If you'd like, you can change the respective strings to your desired language and that's what will appear next to the titles.
Things to Keep in Mind
- Code:
title: [
// phpbb3 && fa edge
'h1.page-title',
// punbb
'.main-head h2',
// invision
'[class="borderwrap"] .maintitle :header'
],
The code above shows the selectors for the title that the "Edit this [...]" link will be appended to. If there is no element that matches them, then there won't be a shortcut link to the page/forum/category/group.
Basically, I'm saying that if you want to be able to edit an html page, then you need to ensure that you have an element somewhere on that page that matches the selector for your respective forum version.
- Forumactif Edge Example:
- Title of HTML Page:
element at the top of my HTML:- Code:
h1.page-title
If the code doesn't work for you, then please leave a reply below and I'll modify the code so that it will work on your forum.
Last edited by Ace 1 on Thu 19 Oct 2017, 13:58; edited 7 times in total
- Wolfuryo
- Gender :
Posts : 256
Points : 3805
Reputation : 81
Language : Romanian and English
Browser : Forum Version :
Haven't tested it yet, but it seems like an interesting feature. Good job on this one!
@skouliki I never got around to trying to make it work for other versions lol.
Tell me if it works now
Tell me if it works now
- Sponsored content
Similar topics
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum