FM Design
Would you like to react to this message? Create an account in a few clicks or log in to continue.

IMPORTANT

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

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

Recent Tutorials
Top posting users this month

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

None

[ View the whole list ]


Most users ever online was 515 on Tue 14 Sep 2021, 15:24

"Edit this page" feature

View previous topic View next topic Go down

Ace 1
Ace 1
Valued Member
Gender : Unspecified
Age : 25
Posts : 2153
Points : 5527
Reputation : 95
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
https://fmdesign.forumotion.com/u190

PostAce 1 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]:


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:



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
Wolfuryo

Gender : Male
Posts : 256
Points : 3805
Reputation : 81
Language : Romanian and English
Browser : Browser : Mozilla Firefox Forum Version : Forum Version : Other

PostWolfuryo Sun 20 Aug 2017, 11:43

Haven't tested it yet, but it seems like an interesting feature. Good job on this one! Smile
Ace 1
Ace 1
Valued Member
Gender : Unspecified
Age : 25
Posts : 2153
Points : 5527
Reputation : 95
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
https://fmdesign.forumotion.com/u190

PostAce 1 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
Ace 1
Ace 1
Valued Member
Gender : Unspecified
Age : 25
Posts : 2153
Points : 5527
Reputation : 95
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
https://fmdesign.forumotion.com/u190

PostAce 1 Tue 17 Oct 2017, 12:54

Dang, eval is evil.
skouliki
skouliki

Gender : Female
Posts : 376
Points : 3916
Reputation : 173
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki 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?
Ace 1
Ace 1
Valued Member
Gender : Unspecified
Age : 25
Posts : 2153
Points : 5527
Reputation : 95
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
https://fmdesign.forumotion.com/u190

PostAce 1 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
skouliki
skouliki

Gender : Female
Posts : 376
Points : 3916
Reputation : 173
Language : english,greek
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
http://iconskouliki.forumgreek.com https://www.facebook.com/iconskouliki https://twitter.com/iconskouliki

Postskouliki Fri 20 Oct 2017, 01:37

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

thanks for looking it
Sponsored content

PostSponsored content

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