pyronaur / easy-photography-portfolio

Photography Portfolio is a easy to use and elegant plugin made for photographers. Install the plugin, add portfolio entries and you have a portfolio!
https://wordpress.org/plugins/photography-portfolio/
GNU General Public License v3.0
25 stars 7 forks source link

Layout again (2) #8

Closed kernel52 closed 6 years ago

kernel52 commented 6 years ago

Hi Norris,

coming back to my efforts on creating a new template as masonry is not exactly what I want.

I am using minimalist-portofolio as my basis, and try to create a new template for a single portofolio.

I followed your wiki, plus your suggestions on my previous question, I can see that my new template can be selected on the back-end, and I can also have my custom thumbnail size.

Now the next question would be, that after declaring and switching to the new template, WP is loading the files from the plugin folder under photography-portfolio/public/templates/single. [portofolio-entry.php which is loading files under photography-portfolio/public/templates/gallery]

What is the structure to use, to create a new set of files under my template folder? Kind as like you did with photography-portofolio folder, where you only override the description.php?

Would a similar folder structure under the name of my layout slug suffice?

I attach again the declaration of my template for reference.


namespace grid;

use Photography_Portfolio\Frontend\Layout\Single\Single_Portfolio_Layout;

class Single_Grid_Layout extends Single_Portfolio_Layout {

    public $attached_sizes = [

        'thumb' => 'thumbnail_grid',
        'full'  => 'full',

    ];

    public $appended_classes = [
        'PP_Gallery'       => 'PP_Grid',
        'PP_Gallery__item' => 'PP_Grid__item',
    ];
}
add_action(
    'phort/core/register_layouts',

    /**
     * @var \Photography_Portfolio\Frontend\Layout_Registry $registry
     */
    function ( $registry ) {

        /**
         * Single Horizontal Portfolio
         */
        $registry->add(
        // Fully Qualified class name.
        // You must make sure that your class is included when neccessary, either by autoloading or manually including it
            'grid\Single_Grid_Layout',

            // The layout group. `single` or `archive`
            'single',

            // Your unique layout slug.
            'grid',

            // The title that's going to appear in Portfolio Settings
            esc_html__( 'Grid', 'grid ' )

        );
    });

Thanks, Nikolas

kernel52 commented 6 years ago

I guess I have to work on the photography-portofolio folder for this. No chance of creating a second one.

pyronaur commented 6 years ago

Hi Nikolas, Sorry I missed your ticket when you submitted it the first time.

When you create a new portfolio layout with a slug, for example grid - you can use that slug in all files to modify layout for that particular layout.

Everything that lives in templates directory can be copied to yourtheme-directory/photography-portfolio.

So for example if you want to replace portfolio-entry.php with your theme code, you can create a new file in your theme, like this:

Furthermore, if you want to only change the contents of portfolio-entry.php for grid layouts - you can do that by appending -{slug}.php to the file. In this example, it would look like this: your-theme-directory/photography-portfolio/single/portfolio-entry-grid.php

But it can also be your-theme-directory/photography-portfolio/single/layout-grid.php or your-theme-directory/photography-portfolio/single/description-grid.php

I hope that makes sense.

kernel52 commented 6 years ago

ah! it all makes sense! I did not want to stress you at all!

After all, providing this as a free plugin, I can only be grateful if you have time to answer questions, but would never complain if I got no answer. I was really going for the simple solution of overriding the templates in the end ;)

But thanks a lot taking time to reply, I will work this way and hopefully won't bother you more :)

Thanks a lot again for your time, Nikolas