HTML Link Helper full_calendar plugin breaks links - cakephp

I'm using elements for different menus in my site using CakePHP to create the links, eg:
echo $this->Html->link(
'Home',
array(
'controller'=>'users',
'action'=>'home'
)
);
My links all break when using the full_calender plugin 2.0 branch from Github when I click the link to the full calender page located at
http://localhost/mysite/full_calendar
All the links in my element are broken and become:
http://localhost/mysite/full_calendar/home/
instead of
http://localhost/mysite/home
I've installed the plugin in app/plugin.
I'm using the controller name and view in my links in the element so whats going wrong?

I solved it by adding plugin link to the links not using the plugin;
echo $this->Html->link('home',array('plugin'=>'','controller'=>'users','action'=>'home'));

I suggest using:
echo $this->Html->link('home',array('plugin'=>false,'controller'=>'users','action'=>'home'));
using
'plugin'=>false
works perfectly and it looks cleaner than 'plugin'=>''.

Related

redirect to page and anchor using ChaplinJs

I have a page /hello where i have a link:
<a href="{{#url 'goodbye' }}{{/url}}">
that will redirect to /goodbye. But i want it to use an anchor too, something like /goodbye#message
I have tried doing:
<a href="{{#url 'goodbye' }}{{/url}}#message">
but when I click on it, it will redirect the page to /goodbye. It seems like Chaplin is deleting the anchor.
EDIT:
For the templates I'm using handlebars (with the chapling boilerplate), the {{#url}} helper generates correctly the link ( cf view-helper.js ). In the rendered page i see:
<a href="/goodbye#message">
but when i click on it, it just redirects me to /goodbye
Any idea?
Found a solution, I needed to stop the routing on the link. I just added the class noscript on the tag
<a href="{{#url 'goodbye' }}{{/url}}#message" class="noscript">
I couln't find a different way to do it. Hope this helps someone else
cf : skipRounting on Chaplin.Layout

Drupal 7 > Print Module > print links missing on custom module and views

Print links are missing on my custom module which creates a custom form. Print links are also missing on my custom views. I searched the internet and people pointed me to configuration menu for print module to look there and check "Show link in system(non content) pages. I did that and I even activated it for all pages with no luck.
What am I doing wrong?
As far as I know, the Print module only outputs links on node pages. I also found the following on the module page
This module allows you to generate the following printer-friendly
versions of any node.
What I sometimes do to solve this is to make a custom block, which takes the page URL and prepend /print. E.g.
<?php $current_url = getenv('REQUEST_URI'); ?>
<img src='/sites/all/modules/print/icons/print_icon.png'>
<a href='/print<?php print $current_url; ?> '>Printer-friendly version</a>
Source of example

where to load javascript in a view page Cakephp

i am working on a Cakephp 2.x .. right now i am loading my js and css files like this
View/Layout/default.ctp
<?php echo $this->fetch('css'); ?>
<?php echo $this->fetch('script'); ?>
<?php echo $this->fetch('scriptBottom');?>
and in each view file i am doing this because there are some pages i am loading different css and js files
for example
View/users/index.ctp
echo $this->Html->script('libs/modernizr.custom',array('inline' => false));
$this->Html->css('reset3860.css', null, array('inline' => false));
echo $this->Html->script('libs/jquery-1.8.2.min', array('block' => 'scriptBottom'));
now the first problem i am facing right now is when i have to write js at the bottom of view page for example if i am submitting a form through ajax .. i can't write at the bottom of the index page ... because if i write there the js will go at the middle or center of the page so now what i do is i go the default.ctp and write there..
so i want to write at the bottom of the index page so it can easily managable and i can see it well what i am doing
the second question is what is the best way to manage all this ... or is there a way that i can make one file of cs and js ... in which there is only the css and js files are loaded ..and then i include that file in my default . ctp page
You should place scriptBottom block at the bottom of your layout, after content block:
<body>
<?php
echo $this->fetch('script');
echo $this->fetch('content');
echo $this->fetch('scriptBottom');
?>
</body>
And then in your views (notice - NO echo):
$this->Html->script(
'libs/jquery-1.8.2.min',
array('block' => 'scriptBottom')
);
$this->Html->scriptBlock(
"alert('Boom!');",
array('block' => 'scriptBottom')
);
here is very good concept and also i have applied in one of my application, it is working very well
it compatible with CakePHP 2.1, and packaged it as a plugin. And also upgraded the CSS compression from CSSTidy to the more recent and better maintained CSS Min.
The plugin is quick and easy to install. The installation instructions are somewhat long - but that's just to provide clarity.
for detail view you can refer Detail link Cakephp.org also you can see the plugin document and how to use it in your appliation

How to generate 'a href="javascript:void(0)"' like link in cakephp?

How to generate 'a href="javascript:void(0)"' like link in CakePHP?
I make an application, the content will insert into the editor textarea when user click a list of image. I add a class to these images and write some code in the javascript file. Everything is going well.
But the link of the image is a URL address, but not 'href="javascript:void(0)' like URL. Anyone could tell me how to make it in CakePHP?
Thanks in advance!
<?php
echo $this->Html->link(
'/path/to/image/',
'javascript:void(0)'
);
?>
You can either set a path to the image or use the Html helper to generate the image tag code. The second parameter will set the href.
Don't believe there is any dynamic way, however when you are creating your form element you can set it in the options array 'href' => 'javascript:void(0)'

CakePHP Elements - how to put javascript?

I've just started using cakephp elements and they're awesome (I used to use include).
I have an element gallery and an element called comments (for a certain page) and for them I have some javascript code attached to both of them. Do you have any suggestions on how I could include that javascript code in the element? If I simply add it like that it will load javascript before loading the html after the element and I don't think it's very wise.
You could put the Javascript code directly into the element file, or put the Javascript code in into your webroot folder, <cake directory>/app/webroot/js/ and include the file in your layout by using the HTML helper:
echo $html->script("myCode");
If you're worried about the Javascript code executing before the page has completely loaded, then use window.onload or $(document).ready() if you're using JQuery.
If I understand you correctly, you want to have JS specific to a page loading in the header when you call a certain element, but that the JS could be different for each element. You also want the JS to be referenced at the beginning of your HTML document.
This is actually quite easy to do. Just make sure that you have <?php echo $scripts_for_layout; ?> in you <head> tag in the layout you are using.
Then, within the element, just do:
<?php $this->Html->script("js_file", array("inline"=>false)); ?>
js_file is the name of your JavaScript file in app/webroot/js/. In this case, the file would be called js_file.js but you must leave off the .js when referencing it as above.
It doesn't matter where abouts in the element file you put this because the "inline"=>false part ensures it won't actually appear at that stage in the code. Instead, it will appear in the <head> wherever you put <?php echo $scripts_for_layout; ?> in your layout.
In cakephp 3 instead of array('inline' => false) you should use array('block' => true) if anyone is looking for that answer like I was.

Resources