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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:54:44+00:00 2026-06-04T02:54:44+00:00

my posts have body text , in this texts i put short code like

  • 0

my posts have body text , in this texts i put short code like , Now i can find 2 arguments in my text (gallery and 2) i want to call Dynamically a function (gallery) in my view and it is calling a element (gallery id = 2) like this :

app/view/posts/index.ctp

findshortcode($posts[Post][Body]); // this function find short code and call his name like gallery(2) 

//my problem is :

function gallery($id = null){
    $this->element('gallery', array('galleryid' => $id), array('plugin' => 'gallerys'));  
}
  • 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-04T02:54:46+00:00Added an answer on June 4, 2026 at 2:54 am

    What you have there does not make a whole lot of sense, and the way you are describing doing it is not the Cakish or MVC way of doing things. But I think I get your question and will explain to you the way you want to do it.

    What you need to do is this… Do all the logic from inside the controller… then send all finished variables to the view for display…

    class PostsController extends AppController {
    
    var $shortCodeTypes = array('gallery');
    
    function view($id){
        $post = $this->Post->find(null, $id);
        $post = $this->_insertShortCodes($post);
        $this->set(compact('post'));
    }
    
    function _insertShortCodes($post){
    
        foreach($this->shortCodeTypes as $shortCodeType){
            // Do logic to find shortcodes and insert data into post body
        }
        return $post
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just starting with Servlets/JSP/JSTL and I have something like this: <html> <body>
I have been staring at this code for hours now and I cannot figure
A user can create a post. Posts have comments. A comment must belong to
I have some XML files of this form: <?xml version=1.0 encoding=utf-8?> <?xml-stylesheet type=text/xsl href=biomirror.xsl?>
I have a body of text that I have to scan and each line
Ok, so I have a form that takes a username and a code. This
In my App, I have different kinds of posts people can make. So I
I have two models ForumThread and Post set-up like this: class ForumThread < ActiveRecord::Cached
I have a form that lets me create new blog posts and I'd like
I have three tables: Post, Attachment, and Media. Posts have Attachments, and Attachments have

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.