Welcome to Geeklog, Anonymous Friday, May 03 2024 @ 06:50 pm EDT

Geeklog Forums

Making 'read more' accessible to registered users only


Gush

Anonymous
How do i make 'read more' accessible to registered users only? such that guest users are prompted to register when the click on 'read more'

 Quote

Status: offline

LWC

Forum User
Full Member
Registered: 02/19/04
Posts: 818
Two guys have tried it in the past.

The first attempt is here and thanks to yours truly it also links to the former one.
 Quote

Status: offline

lbpp

Forum User
Chatty
Registered: 06/10/05
Posts: 57
After reading what has been done in the past, are these hacks still good for the current release of GL? I think this is one of the best ways to "entice" viewers to register for your site. You lure them in with the intro text and then make them register to read the good stuff.
 Quote

Gush

Anonymous
Is there an easy way of doing it guys?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Here's a 1.4 compatible method. Problem really is that GL is not really designed for hiding stories. It's designed for getting information out there.

In public_html/article.php replace
Text Formatted Code
        $story_template->set_var ('story_introtext',
                PLG_replaceTags (stripslashes ($A['introtext'])));
        $story_template->set_var ('story_bodytext',
                PLG_replaceTags (stripslashes ($A['bodytext'])));

 
with
Text Formatted Code
        $story_template->set_var ('story_introtext',
                PLG_replaceTags (stripslashes ($A['introtext'])));
        if (isset($_USER['uid']) and $_USER['uid'] > 1)
        {
        $story_template->set_var ('story_bodytext',
                PLG_replaceTags (stripslashes ($A['bodytext'])));
        }

 
And insert
Text Formatted Code
        if (!isset($_USER['uid']) or $_USER['uid'] <= 1)
        {
            $show_comments = false;
        }
 
After this comment
Text Formatted Code
        // Display the comments, if there are any ..
 

In /path2GL/system/lib-story.php, modify these lines
Text Formatted Code
    $bodytext = '';
    if( !empty( $A['bodytext'] ))
    {
            $bodytext  = stripslashes( $A['bodytext'] );
    }

 
to look like this
Text Formatted Code
    $bodytext = '';
 // someday add a $_CONF['anonmustregtoread'] or even better a $A['regusersonly'] != 0 to this
    $hideregonlycontent = (!isset($_USER['uid']) or $_USER['uid'] <= 1);
    if( !empty( $A['bodytext'] ))
    {
       
        if ($hideregonlycontent)
        {
            // move this into a $LANG array
            $bodytext  = '<a href="' . COM_buildUrl($_CONF['site_url'] . '/users.php?mode=new') . '">Register</a> to read the rest of this story.';
        }
        else
        {
            $bodytext  = stripslashes( $A['bodytext'] );
        }
    }

 
And this line:
Text Formatted Code
    $show_comments = true;
 
becomes this
Text Formatted Code
    $show_comments = !$hideregonlycontent;
 

And that should do it.
 Quote

All times are EDT. The time is now 06:50 pm.

  • 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