User login
Embedd Drupal Login anywhere
<?php global $user; ?>
<?php if ($user->uid) : ?>
<span>Welcome, </span>
<?php print ($user->name); ?>
<?php print l("Your Account",'user/'.$user->uid); ?>|
<?php print l("Sign Out","logout"); ?>
<?php else : ?>
<?php print drupal_get_form('user_login'); ?>
<?php endif; ?>
You can use this inside a block, just make sure that you have your PHP mode filter in order for this work. You can also have this add to your theme templates whenever you have the ability to do so. Hope this helps.
Update Drupal site Anonymously
There are times that when you are dealing with drupal, you are forced to make an update. But what if you are not currently logged in to the site or in worse cases, your site had an error.
Hide 'Tags' label when there is no taxonomy term associated to node - Artisteer theme
There is this annoying feature, found in artisteer theme. It is when it tries displays the 'Tags' label when there is no taxonomy terms at all, associated to a certain node. It should only get visible when there are terms for that particular node. This usually happens when you try to display a node in a view in teaser format or, at the node page, full view.
I tried to look up an answer on how to solve this issue and this is what I come up after digging into the Artisteer theme folder.
At the default theme folder of our Drupal site, we locate the 'common_methods.php' file.
Ope the file. We then search for the function named 'art_node_worker($node)'
Look for it's first 'if' statement which is looking like this
if (!empty($links_output) && !empty($terms_output)) { ..
Put a double backward slash '//' in front of the 'if' so that we make a inline comment.
Immediately, after that commented statement we put this line
if (!empty($terms_output)) {
It should now look like this
function art_node_worker($node) {
$links_output = art_links_woker($node->links);
$terms_output = art_terms_worker($node->taxonomy);
$output = $links_output;
//if (!empty($links_output) && !empty($terms_output)) {
if (!empty($terms_output)) {
$output .= ' | ';
}
$output .= $terms_output;
return $output;
}NEXT, search for the function named 'art_terms_worker($terms)'
Right after this statement $result = ''; , enclose everything with an 'if' statement, and an 'else' after the 'if', which should look like this
function art_terms_worker($terms) {
$result = '';
if ($terms) {
$links = array();
ob_start();?>
<span class="art-posttagicon"><?php
$result .= ob_get_clean();
$result .= t('Tags: ');
foreach ($terms as $term) {
$links[] = l($term->name, taxonomy_term_path($term), array('rel' => 'tag', 'title' => strip_tags($term->description)));
}
$result .= implode(', ', $links);
ob_start();?>
</span><?php
$result .= ob_get_clean();
return $result;
}
else {
return $result;
}
}Save the file.
Remove H1 title on a block - Artisteer theme
We had faced this issue while we are dealing with a block, specifically a webform block. Webform block when being set to display as 'full' will use the exact title element as being used within it's full node's view page.
We had this block being displayed to different pages and each of our pages has it's own title as h1 too. We don't that to happen that for each pages would have 2 entities of h1, since this is not a good SEO practice.
I thought, that this block were the only block who's using h1 as it's title, so I tried to find a way that I can distinguish it from all other blocks and then once found, have it's title removed
At the default theme directory being used, I went inside the 'block.tpl.php' file. From there, there is a variable named '$block'.
Using this code
<?php
print_r($block);
?>Find the line where it says <?php echo $content; ?>and replace it with this new code.
<?php echo ($block->bid == [ the block id ]) ? strip_tags($content, "<input><div><span><a><img>") : $content; ?>The written code means, if the block id is [ the block id ], then it will print the content, but only allowed the specified tags such as <input>, <div>, <span>, <a>, <img>. Otherwise, all other tags are disregards, and thus the H1 is removed. If it is not the block id, then it will just print the $content normally.
Quick Tips : Breadcrumb Customization (Drupal 7)
Breadcrumb is one of nightmare for drupal site. But with simple trick and nice module this issue will be fixed in no time.
Creating Feeds using Drupal views
Feeds are one way to present information over the Internet. My google reader is my favorite tool for retrieving feeds from my favorite websites.