IMPORTANT

FM Design is in read-only mode, please click here for more information.

Latest topics
» 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

» Forumactif Edge - Releases
by Ange Tuteur Thu 14 Dec 2017, 11:25

» [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

» Numbering of messages in the topic
by SLGray Mon 04 Dec 2017, 22:40

Recent Tutorials
Top posting users this month
Who is online?
In total there are 2 users online :: 0 Registered, 0 Hidden and 2 Guests :: 2 Bots

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 : 2153
Points : 3025
Reputation : 92
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 : 256
Points : 1306
Reputation : 81
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 : 2153
Points : 3025
Reputation : 92
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 : 2153
Points : 3025
Reputation : 92
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 : 376
Points : 1416
Reputation : 172
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 : 2153
Points : 3025
Reputation : 92
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 : 376
Points : 1416
Reputation : 172
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