I updated views in drupal 7 and am getting rogue "?>" symbols rendering on my pages for regions I created in a zen sub theme.
The code for one of the regions follows:
<!--/#adbanner-->
<?php if ($page['adbanner']): ?>
<div id = "adbanner" role = "banner">
<?php print render($page['adbanner']); ?>
</adbanner><!-- /#adbanner-->
<?php endif; ?>
Okay, let's try to debug this:
Start by deleting all of your content from your files (do it with a ctrl + a, ctrl + x and then paste it into a new file - this way we can be sure that ALL of the content is gone). Save the files and render the page.
If the symbols continue to pop up, it is an encoding marker that you will have to turn off. If they stop, it is not an encoding issue and we will have to try something else.
NOTE: When I say delete all of the content, make sure that you keep the structure, i.e. the calls to load any external files. Just make sure that the visible content of those files is removed.
Related
How to resize civicrm images(uploaded via webform) in Drupal views.
The images are getting displayed but the width and height are of the size when they upload images..
2 solutions come to mind
Use css to give each image a max-width property. This will make images appear correctly, but won't save bandwidth as the full image will be downloaded and scaled client-side.
Use a drupal module such as Image Resize Filter
If you need more advanced resizing / image transformation options, you can create a custom template file for the image URL field and use drupal image style (admin/config/media/image-styles) to define the required conversion.
As CiviCRM is protecting the files (we don't have the files urls in the database since 4.4.4 ?), you need to use imagecache_external (didn't manage to make image_style_url work). The drawback of this module is that the image is duplicated in drupal.
Anyway, to make this work :
install imagecache_external, go to the configuration page (http://YOUR_SITE/admin/config/media/imagecache_external) and add YOUR_SITE to the white list
create a style http://YOUR_SITE/admin/config/media/image-styles/add
configure the view as needed and add the CiviCRM Image URL field
Edit the view -> Advanced -> Information
Find the file name corresponding to the field you want to customize and create the file with this file name in YOUR_THEME/templates/
Paste the following code (replace 'thumbnail' with the style name you have created) :
<?php
if ($row->{$field->field_alias} != '') {
print theme('imagecache_external', array(
'path' => $row->{$field->field_alias},
'style_name'=> 'thumbnail'));
}
?>
back to Edit the view -> Advanced -> Information -> Rescan templates file and then save the view.
This didn't quite work on a drupal 7 / CiviCRM 5.10+ system (don't know if it still works on earlier).
To make it work put this in the template file:
<?php
$path = $field->render($row);
if (!empty($path)) {
print theme('imagecache_external', array(
'path' => $path,
'style_name'=> 'thumbnail'));
}
?>
In the index action of my UsersController I want to pass strings and arrays to view, so that my View is render correctly. I don't know what am I doing wrong but my view file is not getting one of my array to view.
$users = $this->User->getUsers();
//Setting all variable that are present in layout
$this->set('title_for_layout','Users - Admin');
$page_headings = array("text" => "Users", "clss" => "icon-head");
$this->set('page_heading', $page_headings);
//Ends here
//This is actually going to action view file
$this->set(compact('users'));
My View file Code is like this
<div><?php echo $page_heading[0]['text']; ?></div>
<?php foreach($users as $user){ ?>
I am able to get $users variable here but noting getting $page_heading.
I am getting this error Undefined variable: page_heading.
I have tried everything like these:
$this->set($page_headings);
$this->set(compact('page_headings');
and yes I have change my variable name in view file also to page_headings after doing above code. I am not able to get it working. Can Please anybody help.
Thanks in advance.
This was happened because I was editing my live server file directly from filezilla's edit option and when I was saving it after editing file, it was somehow becoming the one line code and because of the comment tag all code that I had edited became comments.
I rectified this problem when i took fresh copy from server.
So what I learned today: After say working about half an hour on file, take updated file from server if you editing from filezilla because you don't know how it gonna save the file.
Thanks ndm for your help.
I read this and this.
But i couldn't find the answer.
I have this file, where my action's views exist:
View/MyController/index.ctp
I also have this file
View/Commons/blocks.ctp
Blocks.ctp file includes these:
$this->start('sidebar1');
echo 'Some content';
$this->end();
$this->start('sidebar2');
echo 'Some content more';
$this->end();
So in the "index.ctp" file i want to fetch sidebar1 or sidebar2.
How can i do this?
I wrote this to index.ctp, but didn't work.
<?php echo $this->fetch('sidebar1'); ?>
Also this one didn't work
<?php echo $this->fetch('../View/Commons/blocks.ctp/sidebar1'); ?>
Thank you
Put at top of your index.ctp:
$this->extend('Common/blocks.ctp');
With blocks and view inheritence, you can create "sub layouts" which are basically analogous to the standard Cake layout file. So you'd have the main layout.ctp, and the controller-action view ctp would be based on a parent view file (e.g. /Commons/xxxx.ctp) which is "populated" via blocks.
Blocks are like elements but less "formal" unless you use the "view inheritance" features. Their markup & data get created in your scripts, in possibly multiple locations so they can be more cumbersome to debug/maintain (i.e. imagine appending markup to a block from multiple classes). They're also harder to reuse if you don't use inheritance.
Elements are more like stand-alone view files that can be used within any controller+action view or layout: all the markup is in one place and you just pass in the data.
Bottom line: if you're new to Cake, you can get by fine with just elements. View inheritance can help make views/layouts more elegant but at the price of some complexity.
I am using cake 1.3 and i had tried to implement favicon..But some strang error happens and sometime its showing favicon but for sometimes its not showing it.Pronlem is cakephp img folder path is changing>How can i escape from this problem.
i have used below code in my default.ctp
<?php echo $this->Html->meta('favicon.ico','../../app/webroot/img/favicon.ico',array('type' => 'icon'));?>
Favicon shows for following url.
http://localhost/finalportal/index.php/events/eventlist
Favicon not showing for followin url
http://localhost/finalportal/index.php/productsServices
I had tried this also.
<?php echo $this->Html->meta('favicon.ico',/favicon.ico',array('type' => 'icon'));?>
in this case favicon path is not correct
What i am doing wrong
meta('favicon.ico',$this->webroot.'img/favicon.ico',array('type' => 'icon'));
It works perfectly, just create favicon.ico image in img folder.thats it.
Don't use relative paths in the HtmlHelper, Cake prepends the correct path for you.
I haven't use the meta function, so I'm not sure if it respects the Cake directory conventions (e.g. images are in img, JavaScripts in js), but this should work:
<?php echo $this->Html->meta('favicon.ico','/img/favicon.ico',array('type' => 'icon'));?>
use following code to get right path.
<?php echo $this->Html->meta('favicon.ico',$this->webroot.'img/favicon.ico',array('type' => 'icon')); ?>
The problem in the first version is that you're using relative paths so it will always end up pointing to the wrong place, depending on how many parameters the URL has. ../../app/webroot means "two levels down, then to directory app/webroot". Two levels down from http://localhost/finalportal/index.php/events/eventlist is http://localhost/finalportal/index.php/, but two levels down from http://localhost/finalportal/index.php/productsServices is http://localhost/finalportal/, so you end up in the wrong place.
The reason why the second method (which is syntactically correct) doesn't work is probably because you have the server set up wrong. Apache's DocumentRoot should point at the app/webroot directory or the .htaccess file in the root directory should redirect requests to app/webroot.
I've created a custom view template (see link below), which I'm using to bake my views in cakephp.
http://book.cakephp.org/view/789/Modify-default-HTML-produced-by-baked-templates
Everything works fine, but if I try to incorporate an element in my view template, such as
<?php echo $this->element('menu'); ?>
I get an error while baking the view. If I comment out this line, baking works fine.
This is not a huge problem as I can easily comment out the line and edit the views after baking them - I'm just curious why this happens.
EDIT
The error I get in bake is something like "Notice: Undefined property: ViewTask::$element in C:\xampp\xampplite\htdocs\company\app\vendors\shells\templates\views\index.ctp on line 87 ('menu')" - I guess it must be a problem with bake trying to interpret $this->element('menu') rather than just echoing it.
You're exactly right:
"I guess it must be a problem with
bake trying to interpret
$this->element('menu') rather than
just echoing it."
So echo it, e.g.
<?php echo "<?php echo \$this->element('menu'); ?>"; ?>