Drupal 7.. add link in block - drupal-7

I am using drupal 7 and working in my localhost/mydrupal
I want to add a link in a custom block
I wrote
<p>Home | Connect</p>
On click to Home I am in localhost/ instead of localhost/mydrupal
and on click to Connect I am in localhost/user instead of localhost/mydrupal/user
Any idea please to correct this?
Thanks in advance..

Hi you can use $base_url for this
<code>
Example :
<?php
global $base_url;
?>
<p>Home | Connect</p>
</code>

Related

customize and style predefined blocks

I am new in drupal. I want to customize and style my login or my registration form.
There are some predefined blocks in Admin|Structure|Blocks. Login form is one of these predefined blocks and I want to show it in a specific region in my page.tpl.php page. the following code in page.tpl.php shows a login form. I want to style it with bootstrap css. How can I do that?
I have searched a lot and found some code in template.php and so on. But none of them worked. :(
Thank You For Your Help!
<?php if($page['login_region'])
print render($page['login_region']);
?>
You can do like this, just typing html and printing the region, then you can add css with your classes, or you can install Block Class Module to add classes to blocks:
<div class="row">
<div class="col-sm-3 customclass"?
<?php if($page['login_region'])
print render($page['login_region']);
?>
</div>
</div>

cakephp 3 : How to add class in form button?

I have tried this line to add class in cakephp form button, but class is not showing in html
<?= $this->Form->button(__('Login',['class'=>'login-btn'])); ?>
How can I add class in button ?
I think your example doesn't work, because the __() Call shouldn't include the array for the options of the button. Please try the following:
<?= $this->Form->button(__('Login'),['class'=>'login-btn']); ?>
Have a try on this below:
<?php echo $this->Form->button('Login',['class'=>'login-btn']); ?>
A good reference here: Creating input elements
Update
__() is for internalization. Using this will look in to your localization file and output it's corresponding translation. In your case, you include the options inside __() which I think it will cause an error but if it didn't, it will look for it's translated version and also this means ['class'=>'login-btn'] is not considered as an option anymore.
it has to be inside an array : try this
<?= $this->Form->button(__('Login'),array('class'=>'login-btn')); ?>

Drupal 7 overriding node.tpl.php

I am trying to override the front page node, however after following the guide from the official site, it's not working.
Guide: https://www.drupal.org/node/1585528
I have taken node.tpl.php and renamed it to node--front.tpl.php and made changes to the layout, saved and cleared cache. The changes are not being displayed.
Now if I edit node.tpl.php directly it shows the changes, anyone know what I am doing wrong to override specific node templates?
EDIT:
I want to move the title below the image being displayed in the front page.
See below: Moving the title block under the content block, moves the title down as I want it to do, however how do I specify this for just the front page and not all nodes? (renaming node.tpl.php to node--front.tpl.php does not work as mentioned above)
In node.tpl.php: (title block)
<?php print render($title_prefix); ?>
<?php if (!$page): ?>
<h2<?php print $title_attributes; ?>>
<?php print $title; ?>
</h2>
<?php endif; ?>
<?php print render($title_suffix); ?>
(content block)
<div class="content clearfix"<?php print $content_attributes; ?>>
<?php
// We hide the comments and links now so that we can render them later.
hide($content['comments']);
hide($content['links']);
print render($content);
?>
To override the node template for particular node, you need to override the default node.tpl.php. For this copy the existing node.tpl.php file to node--{node_id}.tpl.php.
If you want to override the page template only for front page then you can create page--front.tpl.php file and copy the page.tpl.php file and then modify it as per your requirement.
Still you have issues, then use hook_preprocess_page() in template.php and use dpm() function to find the theme_suggestions that will give the sequence of execution of templates file.
you can use node-{nodeid}.tpl.php
It may help you.
Source: https://drupal.stackexchange.com/questions/39710/how-do-i-define-a-template-file-for-a-specific-node-id
Thanks
Samit K
samitkhulve.com

HTML Link Helper full_calendar plugin breaks links

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'=>''.

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)'

Resources