Welcome to Geeklog, Anonymous Saturday, April 20 2024 @ 06:31 am EDT

Geeklog Forums

Static homepage only for users who are not logged in


Woof

Anonymous
Hopefully the collective can help me...

My goal is to have a static homepage which fills the entire screen when people come to my site for the first time. Once they have registered and are logged in I would like Geeklog to take the user to all the latest stories (sans the homepage). According to the documentation this can be done through a combination of centerblock settings and permissions. Unfortunately, I'm too thick to figure it out.

Can anyone provide me with some instructions on how to accomplish this?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
The phpblock hack in that thread might accomplish something like what you are looking for. Just change the redirect at the end to a staticpage and exclude the staticpage from the if. The function seems to have been munged up by the forum code:
Text Formatted Code
function phpblock_no_anonymous_access()
{
    global $_USER;

    if (!isset($_USER) || !isset($_USER['uid']) || $_USER['uid'] == 1)
    {
        $split = explode('?', $_SERVER['PHP_SELF']);
        if (basename($split[0]) != 'users.php')
        {
            echo COM_refresh($_CONF['site_url'] . '/users.php');
            exit;
        }
    }
    return '';
}

In your case you would create a staticpage and your com_refresh would redirect to $_CONF['site_url'] . '/staticpages/index.php?page=NOUSER' or whatever you call it. You just have to make sure that $_SERVER['PHP_SELF'] is also not that page or else it will infinitely redirect.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Nah, no need for any hacks - the static pages plugin can do that out of the box.

- Create a new static page with the content you want
- check the "Centerblock" checkbox
- in the dropdown menus below that checkbox select "entire page" and "homepage only"
- in the access rights, uncheck the R and E checkboxes for everybody except "Anonymous"

That last step may seem a bit odd, but is required so that you as the owner of the static page are not presented the page every time you visit your index page. You can still edit it, though, provided you're in the Root group. That's a specialty of the Static Pages plugin, btw, and does not work that way with other objects (e.g. stories).

bye, Dirk
 Quote

Status: offline

sacherjj

Forum User
Newbie
Registered: 05/07/07
Posts: 12
Reviving an older thread, because it is exactly what I am trying to do.

I managed to get to the point suggested by Dirk on my own, before trying to figure out how to "finish" the site. What that configuration still lacks is exposure with the Advanced Search block and the links across the top. Is there an easy method of shutting these off?

It looks like the advanced search block is in a template file (leftblocks.thtml), not added with php code, so I'm guessing that I would have to pull it out of the template and make it conditional on if anon user: (!isset($_USER) || !isset($_USER['uid']) || $_USER['uid'] == 1). Currently, I just commented it out of the leftblocks.thml file. Search is available from the link, once logged in.

I have tried to not make the links show up, but must not be changing code in the right place. Is there a single place that I can turn off the links if anon user?

When logged in I see Contribute : Advanced Search : Site Statistics : Directory : Links : Polls : Calendar : My Downloads

After setting all the loginrequired fields under MICELLANEOUS SETTINGS in config.php to 1, I am still getting these showing up:
Contribute : Advanced Search : Site Statistics : Directory : My Downloads

However, when clicking on all by My Downloads a message displays about requiring login. It would be much cleaner to not be there at all. (I always dislike showing an option that really isn't allowed.)

The Filemgmt plugin does not really have an off for Anon, but I have set all categories to not visible for Anon, so it just looks like there are 0 files available.

Thanks for any pointers. Still fairly new at Geeklog, but trying to learn the architecture.

 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
- in the dropdown menus below that checkbox select "entire page" and "homepage only"


If you did this, everything should go away. From the static page, call "echo COM_showBlocks('left'Wink". Assuming the User Block is the only block anonymous has access to (and you have the User Block on the left side), the only thing that should print is the login box. Add additional text in the static page (or in another block) to add any welcome messages.
 Quote

Status: offline

sacherjj

Forum User
Newbie
Registered: 05/07/07
Posts: 12
That is how I have it.

Page Format: Left Blocks
Center block: checked
Position: Entire Page
Topic: Homepage Only
In a block: unchecked
Help File URL: blank
Exit Check: unchecked

Only Anonymous has read.

This still displays links.

It does remove everything when Page Format is set to blank page, but I have to have a link to registration, where they are visible again. Plus, I would have to add a logo to the static page in the method and some method of logging in.

Unless I'm missing something basic....
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
I guess you want to change {menu_elements} to {allowed_menu_elements} in your site's header.thtml. That should only display those links that the current user has access to. Not sure if that works with every plugin, though.

bye, Dirk
 Quote

Status: offline

sacherjj

Forum User
Newbie
Registered: 05/07/07
Posts: 12
Posted with premature celebration. Looks like it kills some of the menus when logged in. At least it sends me in the right direction.

Managed to get My Downloads off, the link for filemgmt. This uses the loginrequired flag defined in config.php. Also posted this fix on PortalParts forum under Filemgmt support for those interested.

Text Formatted Code
geeklog/plugins/filemgmt/functions.inc
Change:
function plugin_getmenuitems_filemgmt()
{
    global $_CONF, $LANG_FILEMGMT;
    $menuitems = array();
    $menuitems["{$LANG_FILEMGMT['downloads']}"] = $_CONF['site_url'] . "/filemgmt/index.php";
    return $menuitems;
}
To:
function plugin_getmenuitems_filemgmt ()
{
    global $_CONF, $_USER, $_CA_CONF, $LANG_FILEMGMT;

    $anon = (empty ($_USER['uid']) || ($_USER['uid'] <= 1)) ? true : false;
    if ($anon && $_CONF['loginrequired'] ) {
        return false;
    }

    $menuitems = array();
    $menuitems["{$LANG_FILEMGMT['downloads']}"] = $_CONF['site_url'] . "/filemgmt/index.php";
    return $menuitems;
}
 Quote

Status: offline

sacherjj

Forum User
Newbie
Registered: 05/07/07
Posts: 12
Got the final piece that fixes it. Since {allowed_menu_elements} doesn't show some of the third party links, I changed {menu_elements} to work as {allowed_menu_elements}.

In lib-common.php around line 739:
Text Formatted Code
Wrap:
if( $last_entry )
{
    $header->parse( 'menu_elements', 'menuitem_last', true );
}
    else
{
    $header->parse( 'menu_elements', 'menuitem', true );
}
$menuCounter++;

With "if ($allowed) { }".  Gives this code (Starting at line 734):
if( !empty( $url ) && !empty( $label ))
{
    $header->set_var( 'menuitem_url',  $url );
    $header->set_var( 'menuitem_text', $label );

    // Added $allowed check JJS 2007-05-08 to fix menu issues.
    if( $allowed )
    {
        if( $last_entry )
        {
            $header->parse( 'menu_elements', 'menuitem_last', true );
        }
        else
        {
            $header->parse( 'menu_elements', 'menuitem', true );
        }
       $menuCounter++;
    }

    if( $allowed )
    {
        if( $last_entry )
        {
            $header->parse( 'allowed_menu_elements', 'menuitem_last', true );
        }
        else
        {
            $header->parse( 'allowed_menu_elements', 'menuitem', true );
        }
        $allowedCounter++;
    }
}


Now everything works. Menus off when anon, on when logged in. Thanks for the pointers in the right direction all.
 Quote

All times are EDT. The time is now 06:31 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