I am new to cakephp and I think I've run into my first problem because I need 2 $content_for_layout in my default layout, like this:
<div id="left_collumn">
<?php echo $content1_for_layout ?>
</div>
<div id="right_column">
<?php echo $content2_for_layout ?>
</div>
I've searched this group and found a thread that suggest using this : http://bakery.cakephp.org/articles/rtconner/2007/08/28/anything_for_layout-making-html-from-the-view-available-to-the-layout and even though I followed the instructions for some reason this is what I always get :http://img38.imageshack.us/img38/3246/sshot1duh.jpg
Do you have any idea why this is happening?
I am not sure what you are trying to do, but maybe you could use an element instead...
http://book.cakephp.org/view/1081/Elements
Read about plugins, thats not the way! Lear to make your own plugin!
Yeah you should use elements instead. Try to go with the rules of the framework whenever you are working on it. There is no need to change the way how Cake PHP handles it, rather using the solutions which framework offers. Use Elements.
http://book.cakephp.org/view/1081/Elements
Related
The standard ("ships with Drupal") user page appears to be compacted into the $user_profile() array. Then, it's unpacked and "printed" (to the screen) by the somewhat terse user-profile.tpl.php template:
<div class="profile"<?php print $attributes; ?>>
<?php print render($user_profile); ?>
</div>
Is there a guide somewhere that would help me understand what the typical internal structure of this array is, and what hooks I might need to employ in order to place DIVs, classes and so forth into it, in order to achieve certain basic design goals?
Take a look at https://drupal.stackexchange.com/questions/88407/how-to-create-a-profile-page. I strongly suggest to use the Panels module. It allows you to add blocks, views etc. to your pages and makes theming a lot easier. There are tons of information about Panels on the internet, so I suggest you have a look around first. The following links can be a good start:
https://www.drupal.org/node/496278
https://drupalize.me/search?query=panels
I built a homepage for my WordPress site from scratch, copying the style of the theme Reflex (which I actually bought). I'm doing this because this way the site is faster, and uses a lot less bandwidth.
Original site and my build
But, I'm having trouble getting the featured images, I wrote some quick code just to work it out:
<img src="'.$thumb_img.'-200x200.jpg">
I add "-200x200" at the end of the url which I got from the database. I understand this is not the best way to do this, so the question is: what's the best practice here?
Also: am I right in rewriting WordPress' frontend for performance? Is there a better approach or solution that you can think ok?
Thanks in advance!
Try this:
<?php the_post_thumbnail( array(200, 200) ); ?>
or, if you are not in the loop, try this:
<?php
$post_id = 54; //the post id that you want to display
echo get_the_post_thumbnail( $post_id, array(200, 200) );
?>
Also, please see: https://codex.wordpress.org/Function_Reference/the_post_thumbnail
and http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
I want to be able to create a magnet link using CakePHP's Html Helper. How would I go about doing that?
I've already tried something like:
<?php
echo $this->Html->link($name, 'magnet:.....');
?>
My point: CakePHP sees anything that does not start with 'http://' as a relative URL. At least that's what the manual states.
Of course I could go and hammer (filter) out the 'http://' after having put it there before the 'magnet'-part.
But is there some (better) way for this without resorting to non-CakePHP-assisted HTML code?
You're forcing something that you don't need to do. The largest draw to using Cake's $html->url() function is to quickly and easily generate dynamic urls that work with Cake's routing. That has little to do with magnet urls. I'd say just go old-school here.
<a href='magnet:<?php echo $magnet_url; ?>'>Magnet Link</a>
I have a fat view (add) with a lot of inputs (it's a form).
For a role , there is a user_id input that is necessary, but for another role it isn't necessary. Here it comes my question, I know that elements are used for this kind of things, but I would be duplicating a lot of code if I make a view with this input and another one without it. Is there any way to just replace a line of code depending on the role? How would it be?
Thank you very much in advance, have a nice day!
What's wrong with a good old if?
<?php if ($theRoleOfTheUser == 'someSpecificRole') : ?>
<div><?php echo $this->Form->input(…); ?></div>
<?php endif; ?>
I am using cakePHP v1.26.
In the default.ctp file,
I got a single of this code in it:
$session->flash();
I came a corss a web site in which the author suggested using this instead:
if($session->check('Message.flash')){
$session->flash();
}
I do not understand what this line of code is doing:
if($session->check('Message.flash')){...}
what is "Message.flash" in this case?
Is "Message.flash" a custom variable or
a built-in varibale which has been predefined in cakePHP?
Message.flash is the session variable name. It will be defined by cakephp, when you use $this->Session->setFlash('Your message'); from your controller.
if($session->check('Message.flash')){...} checks, if session Message.flash, which contains the flash message, exists.
Note also that contrary to the current manual description, $session->flash() does not echo the result, it just returns it, so you will need to have
echo $session->flash();
in your view.
For latest cakephp version
if(!($this->Session->check('Message.flash')));
// your code
In view section for show messages.
$this->Session->flash();