Good art is a taste, good design is an opinion.


Come as guest, stay as family.
Board Index

Come as guest, stay as family.


You are not connected. Please login or register

Foto

[Javascript] Category Protect



View previous topic View next topic Go down Message [Page 1 of 1]

1
Offline

  Shadow

Shadow
Administrator
Administrator

[Javascript] Category Protect Alerte10

Tutorial: Category Protect

Simple IPB protection for non-registered users. Guests can't open a protected category.


--> Tutorials, tips and tricks <--
Category Protect



- Javascript:
Placement: In home page
Code:
[panda=js]        $(function() {
        if (document.getElementById('logout') == null) {
        var sCategory = 'POSITION OF THE CATEGORY';
        $('.main-content:eq(' + sCategory + ')').addClass('protect');
        }
        });
[ic]var sCategory = 'POSITION OF THE CATEGORY';[/ic] - 'Position of the category' change with a number of category. For example: If you have only 2 categories (general and off topic) and you want to protect off topic from guests write [ic]var sCategory = '1';[/ic]

nanako wrote:[link="/t520-javascript-category-protect#3152"]I'm not sure but I think category number starts with 0 so if you have 2 categories and want to protect the SECOND CATEGORY it must be [ic]var sCategory = '1';[/ic].


- CSS:
Code:
[panda=css].protect:after {
              background: none repeat scroll 0px 0px rgba(255, 255, 255, 0.7);
              bottom: 0px;
              content: "Members Only";
              font-size: 30px;
              left: 0px;
              line-height: 300px;
              position: absolute;
              right: 0px;
              text-align: center;
              top: 0px;
              z-index: 10;
        }
        .protect {
              position: relative;
        }


- Preview:
[Javascript] Category Protect Untitl10




© PunBB Design


[Javascript] Category Protect Act_bottom If you have any questions related to this topic create a topic with the following title:
Category Protect

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

2
Offline

  nanako

nanako
Punbb Guru
Punbb Guru
I'm not sure but I think category number starts with 0 so if you have 2 categories and want to protect the SECOND CATEGORY it must be [ic]var sCategory = '1';[/ic].

Powered by PunBB
Currently 0 users have thanked nanako for this post:

3
Offline

  Guest

Anonymous
Guest
nanako wrote:[link="/t520-javascript-category-protect#3152"]I'm not sure but I think category number starts with 0 so if you have 2 categories and want to protect the SECOND CATEGORY it must be [ic]var sCategory = '1';[/ic].
Yes, you are right nanako.
This is really an awesome tutorial.

Powered by PunBB
Currently 0 users have thanked Guest for this post:

4
Offline

  Shadow

Shadow
Administrator
Administrator
Thread updated.

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

5
Offline

  abed_abed

abed_abed
Newbie
Newbie
thank

Powered by PunBB
Currently 0 users have thanked abed_abed for this post:

6
Offline

  Zildjian

Zildjian
Punbb Junior
Punbb Junior
its kinda bug. even the administrator cant access the protected category.

Powered by PunBB
Currently 0 users have thanked Zildjian for this post:

7
Offline

  JScript

JScript
Punbb Rookie
Punbb Rookie
@Rapid

Very good, but I'm posting here just to remind you who made this code was me, see:
[Javascript] Category Protect 4bx5Tac

JS

Powered by PunBB
Currently 0 users have thanked JScript for this post:

8
Offline

  Srz

Srz
Punbb Rookie
Punbb Rookie
Let me see..

Powered by PunBB
Currently 0 users have thanked Srz for this post:

9
Offline

  Andrei34

Andrei34
Punbb Rookie
Punbb Rookie
Working for me.

Powered by PunBB
Currently 0 users have thanked Andrei34 for this post:

10
Offline

  skin4fm

skin4fm
Newbie
Newbie
dont work

Powered by PunBB
Currently 0 users have thanked skin4fm for this post:

11
Offline

  Mimóza

Mimóza
Punbb Rookie
Punbb Rookie
What a candy! I'll might use this, thank you! Very Happy

Powered by PunBB
Currently 0 users have thanked Mimóza for this post:

12
Offline

  DeadlyX

DeadlyX
V.I.P. Member
V.I.P. Member
I would like to test this out. Thanks!

Powered by PunBB
Currently 0 users have thanked DeadlyX for this post:

13
Offline

  Sponsored content



Powered by PunBB
Currently 0 users have thanked Sponsored content for this post:

View previous topic View next topic Back to top Message [Page 1 of 1]


Topic URL's

URL
BBcode
HTML

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