Custom Homepage Layout w/o Affecting Gallery Pages Custom Homepage Layout w/o Affecting Gallery Pages
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Custom Homepage Layout w/o Affecting Gallery Pages

Started by Andy_woz, May 17, 2011, 04:55:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy_woz

Hi, is there a way to easily remove the recent additions and gallery listing from the home page but keep them on the albums page? I know there is a plugin hook $elements = CPGPluginAPI::filter('main_page_layout', $elements); is that the best way to do it? To write a plugin? If so can anyone give a hand with the contents of codebase php? I have so far got this:

// Add a filter for the gallery header
$thisplugin->add_filter('main_page_layout',hide_galleries');

// function
function hide_galleries() {
   
}

Just not sure what the function would be.

Website: http://www.stmarysonlinenursery.com
I could almost do without the category listing at all but isn't it the only way to get in and update the images?

Thanks,

A

Αndré

Replace
// function
function hide_galleries() {
   
}

with
// function
function hide_galleries($elements) {
   
}

and then put the following code into that function to get an idea what you can do:
print_r($elements);

You'll see all elements that will be displayed on the home page. You can remove some of them with the unset function.

Then you need to add a check which page you currently view (e.g. check the category id). Example function (not tested):
function hide_galleries($elements) {
    global $cat;
    if (!$cat) {
        unset($elements['foo']);
        unset($elements['bar']);
    }
    return $elements;
}

Andy_woz

Thanks Andre, can't seem to get it to work in that format. Is there a way to check if it's the home page with a conditional instead? Something like:


function hide_galleries($elements) {
    global $home;
    if ($home) {
        unset($elements['catlist']);
        unset($elements['lastup']);
    }
    return $elements;
}


Or does the home page have a specific ID I can pull?

A

Αndré

The index page usually has the ID '0' or maybe no ID, too. I think it's always '0'. Please post a link to your gallery and your 'home page', maybe we're talking about different things.

Andy_woz

André, Home page is here: http://www.stmarysonlinenursery.com

I'm basically trying to hide the category listing (and possibly the last additions) on the home page but still have it available from the Album List: http://www.stmarysonlinenursery.com/index.php?cat=0
If I go via the admin it removes it from both. The photos are largely going to be accessed via the search so having all the listings on the home page isn't necessary at this point.

A

Αndré

Please post your current plugin code (codebase.php).

Andy_woz


// Add a filter for the gallery header
$thisplugin->add_filter('main_page_layout','hide_galleries');

// function
function hide_galleries($elements) {
print_r($elements);
    global $cat;
    if (!$cat) {
        unset($elements['catlist']);
        unset($elements['lastup']);
    }
    return $elements;
}


The above should cover everything that isn't a cat page correct?

Αndré

Have a look at the output of
print_r($elements);

QuoteArray
(
   [0] => anycontent
   [1] => lastup,2
   [2] => catlist
)

In your setup you have to replace
       unset($elements['catlist']);
       unset($elements['lastup']);

with
       unset($elements[1]);
       unset($elements[2]);

Andy_woz

André this works but removes those page elements on the Album Listing page also index.php?cat=0

Αndré

Try to replace
    if (!$cat) {
with
    $superCage = Inspekt::makeSuperCage();
    if (!$cat && !$superCage->get->keyExists('cat')) {

Andy_woz

That did it André! Many thanks.

I did see $supercage in the docs but not being familiar I would have had quite a time putting something together. Hope this is helpful to others down the road.....

A

Joe Carver

You can try my plugin that does the exact same thing....
      
Album List - Change Page Layout (Album list link)


It will also allow you to change the look of a few index pages....

Andy_woz

Thanks Joe,why isn't your plug in listed on the plugins page? Might have made life a bit easier, still always good to learn something new.

A

Αndré

Quote from: Andy_woz on May 18, 2011, 02:40:02 PM
why isn't your plug in listed on the plugins page?
That list is very outdated, because nobody updates it at the moment. It's already a quite long time on my to-do list, but I wasn't able to update it yet. Currently it's the best to have a look at the plugin contributions board if you're looking for plugins.