I want to add a view block in a new custom region that I had made in drupal 7
Here is what I am doing:
1. regions[grid_first] = 'Grid First' in theme.info file
2. <?php if ($page['grid_first']): ?>
<div id="grid_first" class="column sidebar"><div class="section">
<?php print render($page['grid_first']); ?>
</div></div> <!-- /.section, /#grid_first -->
<?php endif; ?>
this code in page.tpl.php inside my theme folder to call the block in this region
But I am not able to view my block. Where Iam doing wrong?
From Structure > Blocks you can assign any block to your region. The blocks created through views will also be available there.
If you don't see your region displayed there, try clearing cache.
Related
Someone posted another question https://drupal.stackexchange.com/questions/195860/how-does-one-concatenate-fields-in-title-field-in-panels-pages but its not working for me.
I need to concatenate a custom text as prefix with %node:field_city_title keyword while adding a node field in mini-panels.
I tried with Event in %node:field_city_title , Event in%node:field_city_title and searched a lot but nothing works for me.
If you any idea, let me know
I've figured out but not sure either it's a standard way or not but I believe override title field is not accepted "prefix or postfix" for %keyword like mentioned in the question.
Solution
1) Removed tag h1 from the attached image in the question.
2) Created new tpl named as panels-pane--event-node-title.tpl.php and added some code in it
<div class="pane-content">
<?php if ($title): ?>
<h1> <?php print $title; ?> </h1>
<?php else : ?>
// Here we can set any prefix or postfix within the tag
<h1> Event in <?php print render($content); ?> </h1>
<?php endif; ?>
</div>
$content variable will get content of the field along with its all settings (ID, class, tag etc.)
Hope, this will help someone. Thanks
CakePHP Code
<?php echo $this->Form->create('KPI');?>
HTML Output
<form accept-charset="utf-8" method="post" id="..." action="...">
<div style="display:none;">
<input type="hidden" value="POST" name="_method">
</div>
I want to delete auto generated div which display in html output. How can delete that div which generated by cakephp form create?
As already mentioned in the comments, you should not remove that markup, besides that would only be possible by completely overwriting FormHelper::create(), see
https://github.com/.../cakephp/blob/2.5.6/lib/Cake/View/Helper/FormHelper.php#L426-L432
https://github.com/.../cakephp/blob/2.5.6/lib/Cake/View/Helper/FormHelper.php#L462-L464
Also note that there might be an additional hidden block at the end of the form, see FormHelper::secure().
The only simpler way to remove the wrapper, would be to remove the hidden wrappers altogether, that would for example be possible by using a custom config for HtmlHelper where the hiddenblock tag is modified so that it doesn't contain the wrapper, however that's not a good idea - don't do it!
The problem here is that you can't just remove this specific wrapping div element, the hidden input and the div go hand in hand. And the input ensures that CakePHP is able to figure the proper request method (POST, PUT, DELETE).
So instead simply make your jQuery selector more specific, do not just select div elements, instead make sure that your elements have a proper class set, and then select them by that class.
<?php echo $this->Form->create('Kpi', array(
'inputDefaults'=>array('div'=>'false', 'label'=>false)));
?>
Can we do something like image below on cakephp. If can, how to do it? I am struggle with it. I try to find any answers but can not found something like this. Any answers for this problem will be great appreciated.
This can also be done with Bootstrap as well. The functionality is generally the same as #Anubhav 's answer from a bit earlier, however this is a little cleaner and a more up to date solution. The Bootstrap Framework is maintained/updated a lot more frequently.
See here for full solution:
Bootstrap dropdown checkbox select
No you cant do this using only CakePHP... but the above thing can be done using jQuery.
Please follow the link and your task will be done easily
http://dropdown-check-list.googlecode.com/svn/trunk/doc/dropdownchecklist.html
Cheers
multiple dropdown options with checkbox in cakephp error
<div class="col-md-2 place-grid">
<h5>Property Type</h5>
<?php $allCategories=$this->Common->getCategories(); ?>
<?php echo $this->Form->input('ptype',array('options' =>$allCategories,'style'=>'width:150px;','error'=>false,'id'=>'ptype','onchange'=>'getIdType()','div'=>false,'label'=>false,'empty'=>'Select Type','class'=>"sel")); ?>
<?php if($this->Form->error('ptype')){?>
<?php echo $this->Form->error('ptype',array('style'=>'txtError'));?>
<?php } ?>
</div>
<div class="col-md-2 place-grid">
<h5>Sub Type</h5>
<?php $allSubCategories=$this->Common->getArticleSubCategories(); ?>
<?php echo $this->Form->input('sptype',array('options'=>'', 'style'=>'width:150px;','error'=>false,'div'=>false,'select'=>true,'label'=>false,'empty'=>'fgfg','class'=>"sel")); ?>
</div>
I have a
Controller/PostsController.php
Model/Post.php
View/Posts/Index.ctp
if anyone has followed the cakephp blog tutorial i have completed that.
Anyone who hasnt, its basically a site that lets you add a title and a comment. Much like a forum.
Now i have this set up , but i want to include a new page called home. And on this page i wont to display the forum i created but in a smaller container.
I am unsure how to add the view of Posts to a new controller/model/view.
This is PostsController.php:
class PostsController extends AppController {
public function index() {
$this->set('posts', $this->Post->find('all'));
}
}
This is View/Posts/index.ctp
<table>
<tr>
<th>Id</th>
<th>Title</th>
<th>Actions</th>
<th>Created</th>
</tr>
<!-- Here's where we loop through our $posts array, printing out post info -->
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id']; ?></td>
<td>
<?php
echo $this->Html->link(
$post['Post']['title']
);
?>
</td>
<td>
<?php echo $post['Post']['created']; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
so with this, how do i get the same posts to include on a new controller and view, lets say:
HomesController.php
View/Homes/index.ctp
EDIT//EDIT//EDIT
right i have managed to do half of this now by adding
$this->render('/Abouts/index');
to my PostsController
but now i get an error saying
"Undefined variable: posts [APP\View\Abouts\index.ctp, line 12]"
im not sure how to define these in my abouts view
In the 'abouts' action, you'd do the same thing you were doing in the index:
$this->set('posts', $this->Post->find('all'));
Site note: Seems like it would be worth your time to go through the blog tutorial again for a refresher. I believe this kind of thing is covered pretty thoroughly.
From cakephp books
Many applications have small blocks of presentation code that need to be repeated from page to page, sometimes in different places in the layout. CakePHP can help you repeat parts of your website that need to be reused. These reusable parts are called Elements. Ads, help boxes, navigational controls, extra menus, login forms, and callouts are often implemented in CakePHP as elements. An element is basically a mini-view that can be included in other views, in layouts, and even within other elements. Elements can be used to make a view more readable, placing the rendering of repeating elements in its own file. They can also help you re-use content fragments in your application.
So, for your purposes use elements, more information here
in my page I load the content of a div via "ng-include src". In this content I have a <select> item:
<select name="relationship" ng-model="userEdit.relationship">
<?php
$tree = taxonomy_get_tree(5);
foreach ($tree as $row) {
echo "<option value=".$row->tid.">".$row->name."</option>\n";
}
?>
</select>
In my "controller" function I can not to create this tree into an array to pass to "ng-options" because I have no access to source tree via web. I can only read the full HTML form. I can change the source of the form (if I need to inject something for example) but I can not get the original tree in my controller.
However, the HTML is ok, but when I choose my "relationship" and send the form (ng-click="myfunction()") to my controller function i can see that there is no "relationship" in "userEdit" object.
Where is my error ?
Thanks.
You are missing quotes
echo "<option value='".$row->tid."'>".$row->name."</option>\n";