Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
February 09, 2012, 01:19:11 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter
hier
und auf unserer
neuen Webseite
.
149398
Posts in
21080
Topics by
7528
Members
Latest Member:
ronse
WebsiteBaker Community Forum
English
Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
(Moderator:
Argos
)
Handy "edit this page" link when your logged in!
Pages:
1
[
2
]
Go Down
Author
Topic: Handy "edit this page" link when your logged in! (Read 16609 times)
Panther
Offline
Posts: 168
Re: Handy "edit this page" link when your logged in!
«
Reply #25 on:
July 06, 2007, 03:15:04 PM »
There's a system variable for that.. try this..
Code:
<a href="
<?php
echo
LOGIN_URL
;
?>
">member login</a>
I use this to display a link in my templates then is taken from the regular login box, it displays a preferences link, logout link and your name when logged in...
Code:
<?php
if(
FRONTEND_LOGIN
AND !
$wb
->
is_authenticated
()) {
?>
<a href="
<?php
echo
LOGIN_URL
;
?>
">member login</a>
<!-- <a href="
<?php
echo
SIGNUP_URL
;
?>
">register</a> -->
<?php
} elseif(
FRONTEND_LOGIN
AND
$wb
->
is_authenticated
()) {
?>
<a href="
<?php
echo
PREFERENCES_URL
;
?>
">
<?php
echo
$MENU
[
'PREFERENCES'
];
?>
</a>
<a href="
<?php
echo
LOGOUT_URL
;
?>
">
<?php
echo
$MENU
[
'LOGOUT'
];
?>
</a><br />
Logged in as: <span class="caps">
<?php
echo
$wb
->
get_display_name
();
?>
</span>
<?php
}
?>
Logged
Panther
Offline
Posts: 168
Re: Handy "edit this page" link when your logged in!
«
Reply #26 on:
July 15, 2007, 05:03:47 PM »
Ok, I'm trying to get it so this can be done as a module, but I can't even get it to work as a function...
I put the following in a CODE section on a page...
Code:
function edit_this_page()
{
if (is_numeric($wb->get_session('USER_ID')))
{
// Get permissons
if ($page_id) { $this_page = $page_id; }
else { $this_page = $wb->default_page_id; }
$database = new database();
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$this_page'");
$results_array = $results->fetchRow();
$old_admin_groups = explode(',', $results_array['admin_groups']);
$old_admin_users = explode(',', $results_array['admin_users']);
$this_user = $wb->get_session('GROUP_ID');
if (is_numeric(array_search($this_user, $old_admin_groups)) )
{
echo '<a href="'.ADMIN_URL.'/pages/modify.php?page_id=';
if ($page_id) { echo $page_id; }
else { echo $wb->default_page_id; }
echo '" target="_blank"><img align="right" src="'.ADMIN_URL.'/images/modify_16.png" alt="'.$HEADING['MODIFY_PAGE'].' /></a>';
}
}
}
edit_this_page();
and I get...
Quote
Fatal error: Call to a member function get_session() on a non-object in /home/.elijah/mnpages/baker.mnpages.com/modules/code/view.php(30) : eval()'d code on line 3
Any suggestions?
Logged
pcwacht
Guest
Re: Handy "edit this page" link when your logged in!
«
Reply #27 on:
July 15, 2007, 06:56:01 PM »
When using a code section the code will be run through the php interpreter with the function eval();
This is very differrent from using the same code from a module (snippet)
Look at the hello world snippet I once wrote
just replace the echo 'hello world'; with your code and rename the snippet might do just what you need.
Good luck,
John
Logged
marccouture
Offline
Posts: 216
Re: Handy "edit this page" link when your logged in!
«
Reply #28 on:
August 02, 2007, 01:50:32 PM »
Thanks to all who worked on this, very handy indeed. I'll echo others by saying it would be great if this were made available eventually as an installable module, but inserting the code into a template isn't too hard... for the time being.
Logged
Marc C.
RolfP
Offline
Posts: 18
Re: Handy "edit this page" link when your logged in!
«
Reply #29 on:
December 23, 2007, 09:20:26 AM »
I found this code snippet pretty need. Took Panthers code and turned it into a snippet modul. Now I am able to use it in a few servers without much additional effort.
For code see
http://forum.websitebaker.org/index.php/topic,8167.0.html
Have fun
Rolf
«
Last Edit: December 23, 2007, 12:07:12 PM by RolfP
»
Logged
heikal
Offline
Posts: 16
Re: Handy "edit this page" link when your logged in!
«
Reply #30 on:
January 30, 2008, 05:21:15 PM »
Hi there, I'm a newcomer in the scene.
I'm very pleased with WB and I have picked up the code snippets about the handy "edit this page" link of which I think it is a great idea.
When using the code in my template, I have had the same problem having the icon being displayed in the "home" condition (page_id = default).
To cope with this I have slightly changed the routine making it check if the group_id is greater than 1, because the group_id of the top_level page is 1 in my case.
The routine now works perfect and I'm very happy with it. Thanks to all of you.
I hope that this subject was still an issue and that I could eventually help someone.
Good luck and best regards,
heikal
«
Last Edit: April 03, 2008, 01:48:53 PM by heikal
»
Logged
DGEC
Offline
Posts: 386
Re: Handy "edit this page" link when your logged in!
«
Reply #31 on:
January 30, 2008, 06:56:28 PM »
heilcal,
I'm not sure what you mean. Are you saying you had trouble getting the default (home) page to display the edit icon?
Your code does have the correct code to find it, $wb->default_page_id;
What does it do differently?
Logged
nerjuz
Offline
Posts: 6
Re: Handy "edit this page" link when your logged in!
«
Reply #32 on:
February 05, 2008, 08:12:35 AM »
I think this will help to make first page editable
Code:
if (!isset($page_id)) $page_id = $wb->default_page_id;
Code:
<?php
if (
FRONTEND_LOGIN
==
'enabled'
AND
is_numeric
(
$wb
->
get_session
(
'USER_ID'
)))
// Get permissons
$database
= new
database
();
/* Checking*/
if (!isset(
$page_id
))
$page_id
=
$wb
->
default_page_id
;
$results
=
$database
->
query
(
"SELECT * FROM "
.
TABLE_PREFIX
.
"pages WHERE page_id = '
$page_id
'"
);
$results_array
=
$results
->
fetchRow
();
$old_admin_groups
=
explode
(
','
,
$results_array
[
'admin_groups'
]);
$old_admin_users
=
explode
(
','
,
$results_array
[
'admin_users'
]);
$this_user
=
$wb
->
get_session
(
'GROUP_ID'
);
if (
is_numeric
(
array_search
(
$this_user
,
$old_admin_groups
)) ) {
?>
<a href="
<?php
echo
ADMIN_URL
;
?>
/pages/modify.php?page_id=
<?php
if (
$page_id
)
echo
$page_id
;
else
echo
$wb
->
default_page_id
; ;
?>
" target="_blank"><img align="right" src="
<?php
echo
ADMIN_URL ?>
/images/modify_16.png" alt="
<?php
echo
$HEADING
[
'MODIFY_PAGE'
];
?>
" border="0" /></a><br>
<?php
}
?>
«
Last Edit: February 07, 2008, 08:52:25 PM by nerjuz
»
Logged
mercator
Offline
Posts: 79
Re: Handy "edit this page" link when your logged in!
«
Reply #33 on:
March 09, 2008, 03:03:15 PM »
This is great. At the moment, it "only" checks if the current user is an admin and them allows editing or not. Can't one change the code such as to check if the current user (or group the user is in) is allowed to edit and then show the icon as well?
THANKS
Mercator
Logged
janjoensen
Offline
Posts: 7
Re: Handy "edit this page" link when your logged in!
«
Reply #34 on:
March 20, 2008, 09:23:43 PM »
Plc. HELP I can’t not get it to work on may page, and do not find any descriptions how do it.
Sorry I am a beginner!
I have tried what Rolf is writhing in his post 29"; I have also installed his module frontedit.zip. But how and where, shell I but "<?php frontend_edit(); ?>", I have try to edit to template, and puts this string there. I have but this string in to "Resultater - Footer:" and to may font page edit.
«
Last Edit: March 21, 2008, 03:01:28 PM by janjoensen
»
Logged
DGEC
Offline
Posts: 386
Re: Handy "edit this page" link when your logged in!
«
Reply #35 on:
March 20, 2008, 10:56:46 PM »
Try the snippet module up in post #29 - he wrote instructions in the other thread.
Logged
janjoensen
Offline
Posts: 7
Re: Handy "edit this page" link when your logged in!
«
Reply #36 on:
March 23, 2008, 01:11:38 PM »
I have tried what Rolf is writhing in his post 29"; I have also installed his module frontedit.zip. But how and where, shell I but "<?php frontend_edit(); ?>", I have try to edit to template, and puts this string there. I have but this string in to "Resultater - Footer:" and to may font page edit.
Logged
RolfP
Offline
Posts: 18
Re: Handy "edit this page" link when your logged in!
«
Reply #37 on:
March 23, 2008, 04:25:30 PM »
Did you enable front end login?
If so, try to simply add "<?php print "Test"; ?> to prove if there is no error in your template anywhere else.
Logged
Pages:
1
[
2
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
-----------------------------
English
-----------------------------
=> Help & Support
-----------------------------
General
-----------------------------
=> WebsiteBaker Website Showcase
-----------------------------
English
-----------------------------
=> Modules
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
-----------------------------
General
-----------------------------
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
-----------------------------
General
-----------------------------
=> Security Announcements
-----------------------------
Deutsch (German)
-----------------------------
=> Hilfe/Support
-----------------------------
General
-----------------------------
=> Documentation
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
=> Module & Snippets
-----------------------------
English
-----------------------------
=> Archive (posts up to 2007)
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Deutsch (German)
-----------------------------
=> jQuery
=> Tutorials
=> Templates & Design
-----------------------------
English
-----------------------------
=> jQuery
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
===> Suggestions
-----------------------------
Deutsch (German)
-----------------------------
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
===> Vorschläge
-----------------------------
English
-----------------------------
===> Software bugs
-----------------------------
Deutsch (German)
-----------------------------
===> Softwarefehler
=====> Module / Extensions
-----------------------------
English
-----------------------------
=====> Modules / Extensions
-----------------------------
Deutsch (German)
-----------------------------
===> Erfahrungs und Testberichte
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...