Latest topics
» [HELP] About Profile Cover Code
by MaHwOs Yesterday at 18:54

» bloquer un membre
by berlingo Fri 17 Nov 2017, 18:19

» IconSkouliki Graphics
by skouliki Fri 17 Nov 2017, 03:54

» [IN PROGRESS] Can this code work on pun version
by skouliki Thu 16 Nov 2017, 03:50

» Auto-suggest @mentions as You Type
by skouliki Wed 15 Nov 2017, 14:56

» [TUTORIAL] [ALL VERSIONS] Warning before posting
by demon99 Wed 15 Nov 2017, 08:12

» About Add Reply & New Topic button (popup form)
by omarpop23 Mon 13 Nov 2017, 20:31

» Hello everyone this is Adam from France
by Adam Mon 13 Nov 2017, 13:32

» Add a login popup for the toolbar
by Ape Sun 12 Nov 2017, 18:41

» Post a message automatically when locking a topic
by ThunderTB Sun 12 Nov 2017, 13:51

» Control pannel issue
by Ange Tuteur Sun 12 Nov 2017, 09:49

» BUG... forum members birthday's
by Ape Sat 11 Nov 2017, 11:44

» Display a Preview of Groups on Hover
by ThunderTB Fri 10 Nov 2017, 21:56

» Search box only visible on hover
by Ange Tuteur Mon 06 Nov 2017, 09:57

» [GAME] Animal Game
by SLGray Sun 05 Nov 2017, 15:04

Recent Tutorials
Who is online?
In total there are 7 users online :: 0 Registered, 0 Hidden and 7 Guests :: 1 Bot

None

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17

"Edit this page" feature

View previous topic View next topic Go down

avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Sun 20 Aug 2017, 02:00

Just a plugin that displays a link next to the title so that admins can quickly edit pages, forums, categories, and groups.

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:




Code:
h1.page-title
element at the top of my HTML:




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
avatar
Wolfuryo

Gender : Male
Posts : 250
Points : 1240
Reputation : 80
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other
Awards :
View all awards
View user profile

PostWolfuryo on Sun 20 Aug 2017, 11:43

Haven't tested it yet, but it seems like an interesting feature. Good job on this one! Smile
avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Sun 20 Aug 2017, 12:00

@Wolfuryo wrote:Haven't tested it yet, but it seems like an interesting feature. Good job on this one! Smile

Thanks, lol. Razz
avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Tue 17 Oct 2017, 12:54

Dang, eval is evil.
avatar
skouliki

Title :
Gender : Female
Posts : 373
Points : 1340
Reputation : 168
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Thu 19 Oct 2017, 01:36

nice idea !!

i have put the code in my test forum but i cannot see anything (punbb)
is this working with heavy modified templates?

--------

avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Thu 19 Oct 2017, 13:50

@skouliki I never got around to trying to make it work for other versions lol.

Tell me if it works now
avatar
skouliki

Title :
Gender : Female
Posts : 373
Points : 1340
Reputation : 168
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki on Fri 20 Oct 2017, 01:37

maybe its me but i cannot see anything 
the code ia active here

thanks for looking it

--------

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum