Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 09:34 am EDT
Geeklog Forums
Non permission story link in a block appears as text
Status: offline
MartinD
Forum User
Newbie
Registered: 01/15/13
Posts: 13
Why does a non permissioned story link (auto tag) in a right block display as
[story:20130111190308862 Captain's Address] instead of a clickable link "Captains's Address" ?
I have static pages which I don't want anonymous users to see so I set the access rights to non readable.
Martin
PS.
The link works fine for logged in users. I would have thought the link would appear as a normal link but display a login page when clicked if you don't have read permissions.
[story:20130111190308862 Captain's Address] instead of a clickable link "Captains's Address" ?
I have static pages which I don't want anonymous users to see so I set the access rights to non readable.
Martin
PS.
The link works fine for logged in users. I would have thought the link would appear as a normal link but display a login page when clicked if you don't have read permissions.
7
8
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
The difficulty is to handle the access rights to the article because anonymous users will be redirect to index of the site.
If you want to display the link to anonymous you can use autotag plugin. Create a new autotag call linkstory for exemple (check Replace with PHP).
In your lib-custom.php file add this function:
function phpautotags_linkstory ($p1,$p2) {
global $_TABLES,$_CONF;
$result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE sid = '$p1'");
$A = DB_fetchArray($result);
if ($A['count'] > 0) {
if (SEC_hasAccess ($A['owner_id'], $A['group_id'],
$A['perm_owner'], $A['perm_group'], $A['perm_members'],
$A['perm_anon']) >= 2) {
$url = COM_buildUrl($_CONF['site_url'] . '/article.php?story='. $p1);
} else {
// You can custom the page ID here
$url = COM_buildUrl($_CONF['site_url'] . '/staticpages/index.php?page=my_custom_page');
}
$linktext = $p2;
if (empty($linktext)|| $p1==$p2) {
$linktext = stripslashes(DB_getItem($_TABLES['stories'],
'title', "sid = '$p1'"));
}
$content = COM_createLink($linktext, $url);
}
return $content;
}
Then create a php static page with ID: my_custom_page
Select execute php(return) and put this code in the content in text or html formatted
I'm available to customise your themes or plugins for your Geeklog CMS
If you want to display the link to anonymous you can use autotag plugin. Create a new autotag call linkstory for exemple (check Replace with PHP).
In your lib-custom.php file add this function:
Text Formatted Code
function phpautotags_linkstory ($p1,$p2) {
global $_TABLES,$_CONF;
$result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE sid = '$p1'");
$A = DB_fetchArray($result);
if ($A['count'] > 0) {
if (SEC_hasAccess ($A['owner_id'], $A['group_id'],
$A['perm_owner'], $A['perm_group'], $A['perm_members'],
$A['perm_anon']) >= 2) {
$url = COM_buildUrl($_CONF['site_url'] . '/article.php?story='. $p1);
} else {
// You can custom the page ID here
$url = COM_buildUrl($_CONF['site_url'] . '/staticpages/index.php?page=my_custom_page');
}
$linktext = $p2;
if (empty($linktext)|| $p1==$p2) {
$linktext = stripslashes(DB_getItem($_TABLES['stories'],
'title', "sid = '$p1'"));
}
$content = COM_createLink($linktext, $url);
}
return $content;
}
Then create a php static page with ID: my_custom_page
Select execute php(return) and put this code in the content in text or html formatted
Text Formatted Code
return SEC_loginRequiredForm();I'm available to customise your themes or plugins for your Geeklog CMS
6
6
Quote
Status: offline
MartinD
Forum User
Newbie
Registered: 01/15/13
Posts: 13
Hi Ben,
I have completed all the tasks you suggested but at some point (not sure where) I will have to call your new function (phpautotags_linkstory). This function does not replace an existing function so it needs to be called when I'm creating an autotag link. If the user does not have access to the story link they redivert to the login page otherwise the get a valid story link. (or have I not grasped the autotag/link concept ?).
I am a Newbie so I'm not familiar (yet) with all the plugins jargon etc. I do understand PHP.
Cheers
Martin
I have completed all the tasks you suggested but at some point (not sure where) I will have to call your new function (phpautotags_linkstory). This function does not replace an existing function so it needs to be called when I'm creating an autotag link. If the user does not have access to the story link they redivert to the login page otherwise the get a valid story link. (or have I not grasped the autotag/link concept ?).
I am a Newbie so I'm not familiar (yet) with all the plugins jargon etc. I do understand PHP.
Cheers
Martin
6
13
Quote
Status: offline
::Ben
Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Martin,
1. You need to install the autotag plugin
2. Create the "linkstory" autotag on the autotag admin page
3. Add function phpautotags_linkstory to your lib-custom.php file
4. The staic page with ID: my_custom_page
6. In your block create link with [ linkstory : XXXXXXXXXXXXX] where XXXXXXXXXXXXX is your story ID.
For anonymous users link will bring them to the my_custom_page where they can log in
For logged-in users link will bring theme to the story XXXXXXXXXXXXX
The senario is not perfect as "anonymous" will need to click once more on the link to go to the story. We need to handle a redirection just after the user log in...
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
1. You need to install the autotag plugin
2. Create the "linkstory" autotag on the autotag admin page
3. Add function phpautotags_linkstory to your lib-custom.php file
4. The staic page with ID: my_custom_page
6. In your block create link with [ linkstory : XXXXXXXXXXXXX] where XXXXXXXXXXXXX is your story ID.
For anonymous users link will bring them to the my_custom_page where they can log in
For logged-in users link will bring theme to the story XXXXXXXXXXXXX
The senario is not perfect as "anonymous" will need to click once more on the link to go to the story. We need to handle a redirection just after the user log in...
Ben
I'm available to customise your themes or plugins for your Geeklog CMS
12
7
Quote
All times are EDT. The time is now 09:34 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content