2013-02-21 32 views
8

के बजाय एएससीआई उत्पन्न करना मैं केकेएफपी 2.3.0 का उपयोग कर रहा हूं। मैंने मैन्युअल में थोड़ी देर के लिए खोज की, लेकिन मुझे जवाब नहीं मिला है। मैं इस-> एचटीएमएल-> लिंक का उपयोग करने की कोशिश कर रहा हूं, $-- HTML-> छवि के साथ। मैं एक छवि पर क्लिक करने की क्षमता बनाने की कोशिश कर रहा हूं। उद्धरणों के एएससीआई प्रतिपादन के कारण क्यों कोई विचार उत्पन्न किया जा रहा है?

यहाँ मेरी टुकड़ा मेरे विचार सीटीपी में codeset है:

echo $this->html->tableCells(
     array(
      array(
       array (
        $this->Html->link($myActivity['Activity']['name'], array('controller' => 'users', 'action' => 'edit'), array('title' => '')), 
          array('align' => 'left')), 
        array ($myActivity['Activity']['status'], array('align' => 'left')), 
        array ($myActivity['Activity']['any_messages'], array('align' => 'left')), 
        $date2, 
        array ($this->Html->link(
          $this->Html->image('pencil.jpg', array('alt' => 'Edit', 'border' => '0', 'width' => '25')), 
          array('controller' => 'users', 'action' => 'add'), array('title' => '')) 
        ), 
        $this->Html->image('trashcan.jpg', array('alt' => 'Delete', 'border' => '0', 'width' => '25')), 
        $this->Html->image('copy.png', array('alt' => 'Copy', 'border' => '0', 'width' => '25')), 
      ) 
     ) 
    ); 

नीचे से ऊपर कोड की वास्तविक HTML परिणाम है। आप देख सकते हैं, सृजित HTML कोट (") का ASCII संस्करण और '<' और '>' दिखा रहा है:

<tr> 
    <td align="left"> 
     <a href="/activities/index.php/users/add" title="">Running</a> 
    </td> 
    <td align="left">Live</td> 
    <td align="left">no</td> 
    <td>02/18/13</td> 
    <td> 
     <a href="/activities/index.php/users/edit" title=""> 
      <img src="/activities/app/webroot/img/pencil.jpg" alt="Edit" border="0" width="25"></a> 
    </td> 
    <td> 
     <img src="/activities/app/webroot/img/trashcan.jpg" alt="Delete" border="0" width="25"> 
    </td> 
</tr> 
:

<tr> 
    <td align="left"> 
     <a href="/activities/index.php/users/add" title="">Running</a> 
    </td> 
    <td align="left">Live</td> 
    <td align="left">no</td> 
    <td>02/18/13</td> 
    <td> 
     <a href="/activities/index.php/users/edit" title="">&lt;img src=&quot;/activities/app/webroot/img/pencil.jpg&quot; alt=&quot;Edit&quot; border=&quot;0&quot; width=&quot;25&quot; /&gt;</a> 
    </td> 
    <td> 
     <img src="/activities/app/webroot/img/trashcan.jpg" alt="Delete" border="0" width="25"> 
    </td> 
</tr> 

नीचे मैं HTML तरह देखने के लिए उम्मीद करेंगे क्या है

+0

पूर्ण डी हजारों लोगों का उत्थान (साइडबार देखें) – mark

उत्तर

21

आप अपने link() कॉल की विकल्प सरणी के लिए escape विकल्प जोड़ने की जरूरत है, false पर सेट करें इस तरह:।

echo $this->Html->link(
    $this->Html->image('mydog.jpg'), '/lol.html', array('escape' => false) 
); 
+0

बहुत बढ़िया, मुझे पता था कि यह एक आसान फिक्स होगा। जब मैं समय लेता हूं तो मैं इसे आज बाद में आज़मा दूंगा। धन्यवाद मैट। – Kevin

+0

आपको बचने का विकल्प क्यों जोड़ना है? – Jonathan

+0

@defaye यदि आप इसे 'झूठी' पर सेट नहीं करते हैं तो लिंक की सामग्री से बच निकलेगा, उदा। '>' ''और आदि बन जाएगा, जिसका अर्थ है कि आपके लिंक के अंदर HTML काम नहीं करेगा। –

0

इस प्रयास करें:

echo $this->Html->link('', array(
    'controller' => 'Mycont', 
    'action'  => 'deletepic', 
    $id 
), array(
    'confirm' => 'Are you sure you want to delete the image?', 
    'class'  => 'deleteImg' 
)); 

मैंने छवि को हटाया है Img में छवि को लिंक किया है।

1

हां एक छवि को एंकर टैग के रूप में बनाना संभव है। तुम बस नीचे की तरह इसके लिए भागने सेट करना होगा = false: -

<?php 
$thumb_img = $this->Html->image('yourimage.png',array('alt'=>'yoursite.com','class'=>'yourclass')); 

echo $this->Html->link($thumb_img, array('controller'=>'yourcontroller','action'=>'youraction'), array('escape'=>false)); 

?> 
+0

उत्तर संस्करण सर के लिए धन्यवाद :) –

1
echo $this->Html->image('imagename',array('alt'=>'myimage','class'=>'img-responsive')); 

यह, किसी भी लिंक के बिना सामान्य छवि अब लिंक टैग उपयोग के साथ यह लपेटो करने

echo $this->Html->link($this->Html->image('imagename',array('alt'=>'myimage', 'title'=>'myimage','class'=>'img-responsive')), [ 
         'controller' => 'controllerName', 
         'action'  => 'actionName', 
         'id'   => $value['id'], //if any parameters are passed 
         ],['escape' => false]); 

इसी प्रकार आप एक छवि को छवि टैग असाइन कर सकते हैं और इसका उपयोग

$myImageVar = $this->Html->image('imagename',array('alt'=>'myimage','class'=>'img-responsive')); 

echo $this->Html->link($myImageVar, [ 
          'controller' => 'controllerName', 
          'action'  => 'actionName', 
          'id'   => $value['id'], //if any parameters are passed 
          ],['escape' => false]);