English 中文(简体)
• 如何从其他控制者手中接过该网页的一部分
原标题:How to get part of the page from other controller
  • 时间:2012-01-13 07:54:35
  •  标签:
  • php
  • symfony

My site I have some content can be voted (+/-). It is working fine now, when all content has its own voter. Now I m looking for a way to create a single voting bundle with a entity(votedModel,votedId, user, vote). Basically the bundle is ready. My problem is how to use it. I d like to be able to do something like:

class ... extends Controller {
    function showAction(Request $request,$id) {
        ...
        $voter=new Voter( myCOntentType ,$id,$userid);

        ...
        return $this->render( ... , array( voter =>$voter->getVoter(),...))
    }
}

选民意见。

  • 但是,我对如何确切开始感到困惑。 我试图以这种方式呼吁其他控制者,但能够创造选民。

  • 它使用<代码>voter=$this->forward( Voterbundle NewAction,ome (id=>$id,user =>$user)->getContent();
    。 但我想到了这 t。

我认为我的做法是错误的,我可能需要这样做。 我无法找到办法。

最佳回答

您可以使用或将其他模板产出列入您的前身模板。 因此,你可以制作一个模板(例如,选民.html.twig),其中载有你的投票制度的超文本,在Twig,在需要选民的地方,你可以使用:

{% include "AcmeVoterBundle:Voter:voter.html.twig" %}

{% render "AcmeVoterBundle:Voter:voter" with {"item": item} %}

在第一个例子中,http://symfony.com/doc/ 当前/book/templating.html# including-other-templates, in the后一种情况,你实际上实施了另一个控制器的行动方法,并将这一方法的输出列入目前的模板(另见:

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签