I'm adding some pages to default layout editor in SE4. What I do is just adding pages to core_pages table and editing core_content table to add a main container and a middle/right two columns layout. Everything works fine, but now I'm adding default Create Video page (videos_index_create) and I got some problems.
When I add this page via sql, I can obviously see and edit page layout by default layout editor. Actually, when I save changes these don't reflect to live page. If I go to the controller (Video/controllers/IndexController.php) and add
$this->_helper->content->setNoRender()
live page displays right sidebar and middle content, but with
$this->_helper->content->setEnabled()
it shows only the default video upload form.
So I edited create.tpl here
<?php if (($this->current_count >= $this->quota) && !empty($this->quota)):?>
<div class="tip">
<span>
<?php echo $this->translate('You have already uploaded the maximum number of videos allowed.');?>
<?php echo $this->translate('If you would like to upload a new video, please delete an old one first.', $this->url(array('action' => 'manage'), 'video_general'));?>
</span>
</div>
<br/>
<?php else:?>
<?php echo $this->form->render($this); ?>
<?php endif; ?>
Changing the else deleting the echo statement and adding a simple echo 'foo';. Now, live page shows properly my layout (middle+right) with default content ("foo").
I figured thus that the issue is about this line in controller:
$this->view->form = $form = new Video_Form_Video();
but I can't go further… this custom form class (Video/Form/Video.php) seems nothing special, I can't really figure out why its rendering crushes default layout render.
Any social engine expert right here to help me? :)
If its a Zend_Form I am pretty sure you should be doing:
<?php echo $this->form;?>
In your view not call render yourself.
If it is NOT a Zend_Form please post the code for the form it probably has some css or whatnot breaking your layout.
Related
I have added a new layout in the Wordpress Custom fields plugin, and after adding it I have added the fields in the corresponding php file too. But for some reason, its printing the code in the browser. I am not sure what I am doing wrong here. I am new to WordPress, so can someone please help me?
Screenshots attached for reference.
PHP file code - https://codeshare.io/GklExO
Figured it out, I had to add an image tag and then it worked fine.
However, there are other PHP files in the site, where
<?php the_sub_field('image'); ?> displays the image, but in this particular case I had to write it as
<img src="<?php echo esc_url($image['url']); ?>"/>
Still trying to understand how this works.
i have a website that if fully dynamic from page building,menus etc now previously before making it dynamic i made static pages for the client and after that he told me make everything dynamic!
i am using summernote editor for dynamic editing now summernote has an option of custom html in which we can write our code so what do i do simply is i copy the code from static pages one by one and add the html to summer note custom html editor side! now everything is working fine as it should but what happens it that on the front end base_url() variable is not echoing the path as it normally should,now the data of the page is received from database the variable syntax is fine i have also autoloaded url in my config file but still it is not working here is a demo of the code.
html
<?php include "includes/header-others.php" ?>
<div id="parent_margin">
<div class="container generic generic_diagnostic">
<?php
print_r($text[0]->page_data); //this line is printing the result from database
?>
</div>
</div>
<?php include "includes/footer-others.php" ?>
An example how data is being stored in db
<img onclick="blur_image(this.id)" src="<?=base_url()?>images/ourteam_1.png" class="img-responsive"/>
i dont know what is the issue! the same html code works fine when using in static pages and on dyamic pages where datab comes from db its does not echo the value of base_url()..
Long time reader, first time poster :)
I'm just embarking on my first Cake app so hopefully you guys can help me on my way.
First question is about extending/including views. I realise the way the layouts/view work is to prevent code having to be repeated, but I can't get my head around how to set up what I want to do without some repetition.
My page layout consists, apart from header and footer, a left nav bar which I want Controllers to add themselves to if appropriate, and a top nav bar which will be populated by appropriate pages within the current controller.
I tried creating a view block from within the controller but it didn't work, I'm a bit stumped.
Here's what I have:
My default layout includes the sidebar, currently just hardcoded, and the content:
Layout default.ctp
<!DOCTYPE html>
<html>
<head>.....</head>
<body>
...
<div id='leftnav'>
This is where I want my left nav
I want controllers to be able to add themselves
here.
</div>
<?php echo $this->fetch('content'); ?>
</body>
</html>
Then my /Customer/index view:
View index.ctp
<?php $this->extend('common'); ?>
<h1>Customers</h1>
.... do stuff with customers .....
Which extends my /Customer/common view to bring in the top nav bar, each view has to include this extend line, it would be nice not to have to if there's a different way of doing this.
At the moment, the links are just fixed but I'd like the controller to be able to create these options.
View common.ctp
<?php
echo $this->Html->Link('index', "index")." ";
echo $this->Html->Link('find', 'find')." ";
echo $this->Html->Link('add', 'add')." ";
echo $this->Html->Link('details', 'details');
echo $this->Session->flash();
echo $this->fetch('content');
?>
Appreciate your help cheers! :D
I think you should just be able to put those links in your layout file. But you may have to re-write them as "$this->Html->link("Index",array("controller => $controller","action" => "index");" etc.
To get the current controller within the layout file you can say "$controller = $this->params['controller']".
right, after searching around I think I found a good way of doing at least one of these things.
For the top nav, where the links will be populated by the controller, I'll pass an array from the controller to view. Then, instead of having an ->extend in every view I'll create an element to turn the array into a nav bar, and ->fetch this in the layout.
This leads me onto my next question....
How much code is ok in a CakePHP Layout?
Hi you can use Cake PHP HTML Helper
https://book.cakephp.org/3/en/views/helpers/html.html#creating-links
echo $this->Html->link('Users List', ['controller' => 'Users','action' => 'index']);
Output will be look like this:
Users List
I am trying to customizing the course page in such way that once the student logged in he should see a button in the center of the screen course layout, i have set the basic requirements in the theme's config.php file. which is shown below.
'incourse' => array(
'file' => 'course.php',
'regions' => array(),
),
How can i add the button in the center of course layout
Button 1
which should take the student to his profile when he clicks it. what should be the code in the main-wrap contents.
<div id="region-main-wrap">
<div id="region-main">
<div class="region-content">
<?php echo $coursecontentheader; ?>
<?php echo $OUTPUT->main_content() ?>
<?php echo $coursecontentfooter; ?>
</div>
</div>
</div>
Firstly, the "incourse" layout is used by pages inside the course structure such as an activity landing page. If you want the actual course to change you will need to modify the "course" layout.
Secondly, the course content itself is rendered by $OUTPUT->main_content(). If you want to put your button above or below the course content you can add it above or below that line.
If you want the button to actually appear within the course somewhere you could try one of the following:
Add the button to your course directly within the HTML editor on the site
Add a div outside your course and position it over the course using absolute positioning in your CSS
Modify your course format directly (not advisable unless you really know what you are doing)
I have a views page that contains a listing of one of my content type. I used views-view-list--<name of my view>.tpl to theme the page. However, the region/blocks that I defined are not displaying. In other pages it works fine, but on the views page it does not. I'm trying to display a user login block in my defined region.
Please tell me how to access my user login block or my region to display on my views.
Your help is greatly appreciated. I'm using drupal 6 by the way.
Best regards,
Think i ran into something similar yesterday. I was trying to print a region, for example
<?php print $footer ?>
but inside a tpl file that came from views - and for whatever reason, it doesn't output the region from one of the views tpl files.
I used this code:
<?php print theme('blocks', footer); // change "footer" to the name of your region ?>
As I am writing this, a safer and maybe recommended way in D7 would be:
<?php
$region = block_get_blocks_by_region('footer') //first define the block;
print render($region) // then print the block;
?>
I tried #Garry but I got some errors back from Drupal. Please see here
Hope this helps someone down the line.
Any page in drupal have page template based on url or content type . So you have to create right page template for your page where views page/block to be displayed. I'm assuming that you are using page template based on url
This worked for me, except the syntax above needs semi-colons after (); for example print render($region); otherwise thank you for this answer
This is how the snippet will work for Drupal 7 with Bootstrap - HTML tags, considering that the 'billboard' region host an ad:
<aside class="col-xs-0 col-sm-12 role="banner">
<?php
$region = block_get_blocks_by_region('billboard');
print render($region);
?>
</aside>