Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7799617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:22:11+00:00 2026-06-02T00:22:11+00:00

I read this and this . But i couldn’t find the answer. I have

  • 0

I read this and this.
But i couldn’t find the answer.

I have this file, where my action’s views exist:
View/MyController/index.ctp

I also have this file
View/Commons/blocks.ctp

Blocks.ctp file includes these:

$this->start('sidebar1');
echo 'Some content';
$this->end();

$this->start('sidebar2');
echo 'Some content more';
$this->end();

So in the “index.ctp” file i want to fetch sidebar1 or sidebar2.
How can i do this?
I wrote this to index.ctp, but didn’t work.

<?php echo $this->fetch('sidebar1'); ?>

Also this one didn’t work

<?php echo $this->fetch('../View/Commons/blocks.ctp/sidebar1'); ?>

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:22:13+00:00Added an answer on June 2, 2026 at 12:22 am

    Put at top of your index.ctp:

    $this->extend('Common/blocks.ctp');
    

    With blocks and view inheritence, you can create “sub layouts” which are basically analogous to the standard Cake layout file. So you’d have the main layout.ctp, and the controller-action view ctp would be based on a parent view file (e.g. /Commons/xxxx.ctp) which is “populated” via blocks.

    Blocks are like elements but less “formal” unless you use the “view inheritance” features. Their markup & data get created in your scripts, in possibly multiple locations so they can be more cumbersome to debug/maintain (i.e. imagine appending markup to a block from multiple classes). They’re also harder to reuse if you don’t use inheritance.

    Elements are more like stand-alone view files that can be used within any controller+action view or layout: all the markup is in one place and you just pass in the data.

    Bottom line: if you’re new to Cake, you can get by fine with just elements. View inheritance can help make views/layouts more elegant but at the price of some complexity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking around for this but couldn't find an answer anywhere, so
I read similar questions to this problem but I couldn't find out why it
I'm sure there is a simple answer to this but I couldn't find it.
I have read this question , but I couldn't create a full example: class
I have been looking around for an answer to my question but couldn't find
I've read a few threads on this subject but couldn't find anything to do
Apologies, but I have searched and read previous answers on this question but couldn't
I have read many topics about UITableViews not refreshing on iPhone, but couldn't find
I read this typedef line in a C++ book, but I couldn't resolve its
I read this question but the answer does not perform a refactoring of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.