getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
632 stars 94 forks source link

create route and controller to modify query and display my CystompPostType.php #129

Closed imajim closed 8 years ago

imajim commented 8 years ago

Hello,

I have un CustomPostType.php (annonces.php) in my wordpress theme with custom query to filter the "annonces". I would like, if it's possible, to capture this url "http://mydomain.com/annonces-immobilieres/param1/param2..." and extract parameters, modify the WP query and displayed my page "annonce.php"

i wrote this :

$router->get([
    'as'   => 'listingAnnonces',
    'uri'  => '/annonces-immobilieres/{typeDeBien}',
    'uses' => __NAMESPACE__ . '\Controllers\AnnonceController@listingAnnonce'
]);
 public function listingAnnonce($typeDeBien=null,$localisation=null,$nbrPiece=null)
    {

    }

but i don't known how to return the view with header, footer , content ..

thanks for help ^^

jeremyzahner commented 8 years ago

@imajim I strongly advise you on reading the documentation in full. Its not that much to read thou. =) That exact part your asking for can be found here: http://getherbert.com/0.9/views

imajim commented 8 years ago

of course, I read this but i need the header and footer also i fix it by :

$router->get([
    'as'   => 'listingAnnonces',
    'uri'  => '/annonces-immobilieres/{typeDeBien}',
    'uses' => __NAMESPACE__ . '\Controllers\AnnonceController@listingAnnonce'
]);
public function listingAnnonce($typeDeBien=null,$localisation=null,$nbrPiece=null)
    {
        ob_start();
        include(locate_template('annonces.php'));
        $content = ob_get_contents();
        ob_clean();
        return view('@AptalisAnnonces/front/annonces.twig', [
            'content' => $content
        ]);
    }

But i suppose it's not a clean solution and the admin bar disappear on admin logged.