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 7838875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:14:39+00:00 2026-06-02T15:14:39+00:00

I’m trying to learn CakePHP by building a simple CMS app, it was going

  • 0

I’m trying to learn CakePHP by building a simple CMS app, it was going well but as I’m adding more, I’m getting a bit confused by the MVC structure.

In addition to my Posts, I have created a simple model for ‘Content Blocks’ (basically an admin editable title and content field) that I want to display as elements within other pages of my site.

To help explain:

My Posts controller has an index action that lists out all of the blog posts. In the view for that action I also want to pull a specific ‘content block’ from the database and display it at the top of the page.

Another example would be an admin-editable ‘about’ blurb that appears in the footer of every page.

Lastly, in a similar fashion to the WordPress text widget or Magento static block, I’d like to prevent ‘content blocks’ being directly accessible (i.e. domain.com/content_blocks/view/id)

What is the ideal way to achieve this whilst staying true to CakePHP and MVC convention?
I’ve had several stabs at it (such as using requestAction in an element) but have only succeeded in getting more confused.

  • 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-02T15:14:40+00:00Added an answer on June 2, 2026 at 3:14 pm

    The way I would do it is as you suggested with a request action inside an element because that won’t be directly accessible through the URL. So you would create a view inside the elements folder:

    app/View/Elements/block.ctp:

    <?php $sidebar = $this->requestAction(array(
        'controller' => 'ContentBlocks', 
        'action'=> 'viewBlock', 
        'yourtitle'
    )); 
    // layout your block here
    ?>
    

    app/Controller/ContentBlocksController.php

    public function viewBlock($title) {
        return $this->ContentBlock->findByTitle($title);
    }
    

    Then you can see this post for how to do caching with the element and requestAction: http://mark-story.com/posts/view/how-using-requestaction-increased-performance-on-my-site

    Also, you might want to checkout Croogo, which has a lot of the functionality you are looking for and more already built in: http://croogo.org/

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a

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.