Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Custom Homepage Layout w/o Affecting Gallery Pages  (Read 5172 times)

0 Members and 1 Guest are viewing this topic.

Andy_woz

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Custom Homepage Layout w/o Affecting Gallery Pages
« on: May 17, 2011, 04:55:04 pm »

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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #1 on: May 17, 2011, 05:07:07 pm »

Replace
Code: [Select]
// function
function hide_galleries() {
   
}
with
Code: [Select]
// function
function hide_galleries($elements) {
   
}
and then put the following code into that function to get an idea what you can do:
Code: [Select]
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):
Code: [Select]
function hide_galleries($elements) {
    global $cat;
    if (!$cat) {
        unset($elements['foo']);
        unset($elements['bar']);
    }
    return $elements;
}
Logged

Andy_woz

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #2 on: May 17, 2011, 05:52:26 pm »

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:

Code: [Select]
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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #3 on: May 17, 2011, 06:29:58 pm »

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.
Logged

Andy_woz

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #4 on: May 17, 2011, 07:06:45 pm »

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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #5 on: May 17, 2011, 07:12:36 pm »

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

Andy_woz

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #6 on: May 17, 2011, 07:19:26 pm »

Code: [Select]
// 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?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #7 on: May 17, 2011, 08:09:41 pm »

Have a look at the output of
Code: [Select]
print_r($elements);
Quote
Array
(
    [0] => anycontent
    [1] => lastup,2
    [2] => catlist
)

In your setup you have to replace
Code: [Select]
       unset($elements['catlist']);
        unset($elements['lastup']);
with
Code: [Select]
       unset($elements[1]);
        unset($elements[2]);
Logged

Andy_woz

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #8 on: May 17, 2011, 08:24:07 pm »

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #9 on: May 17, 2011, 08:56:29 pm »

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

Andy_woz

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #10 on: May 17, 2011, 09:02:04 pm »

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
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #11 on: May 18, 2011, 01:38:59 am »

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

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #12 on: May 18, 2011, 02:40:02 pm »

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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Homepage Layout w/o Affecting Gallery Pages
« Reply #13 on: May 18, 2011, 03:19:46 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.038 seconds with 19 queries.