snipt

Ctrl+h for KB shortcuts

Text only

Drupal 7 : Handle page title with Panels

The config has to be done on the "Content" menu of your Panel page variant.
Set the "Title type" to "Manually set" and leave the field "title" empty. It will be automaticaly filled with the content type title
https://snipt.net/embed/f6de0a7936c308df062e8827e968cc4a/
https://snipt.net/raw/f6de0a7936c308df062e8827e968cc4a/
f6de0a7936c308df062e8827e968cc4a
text
Text only
2
2016-09-25T21:44:00
True
False
True
Oct 29, 2012 at 04:26 AM
/api/public/snipt/48292/
drupal-7-handle-page-title-with-panels
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>The config has to be done on the &quot;Content&quot; menu of your Panel page variant. </span><span id="L-2"><a name="L-2"></a>Set the &quot;Title type&quot; to &quot;Manually set&quot; and leave the field &quot;title&quot; empty. It will be automaticaly filled with the content type title </span></pre></div> </td></tr></table>
"drupal 7", panels, title

PHP

Normalize the title for use as a <div> id

<?=preg_replace("![^a-z0-9]+!i", "-",get_the_title()); ?>
https://snipt.net/embed/87b3b5fe4257739a817c88abbc6889a8/
https://snipt.net/raw/87b3b5fe4257739a817c88abbc6889a8/
87b3b5fe4257739a817c88abbc6889a8
php
PHP
1
2016-09-26T02:58:02
True
False
False
/api/public/snipt/39810/
normalize-the-title-for-use-as-a-div-id
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?</span><span class="o">=</span><span class="nb">preg_replace</span><span class="p">(</span><span class="s2">&quot;![^a-z0-9]+!i&quot;</span><span class="p">,</span> <span class="s2">&quot;-&quot;</span><span class="p">,</span><span class="nx">get_the_title</span><span class="p">());</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
id, title, wordpress

PHP

Display title of the page

<?php the_title(); ?>
https://snipt.net/embed/3228e95d98e148cb065730370a215193/
https://snipt.net/raw/3228e95d98e148cb065730370a215193/
3228e95d98e148cb065730370a215193
php
PHP
2
2016-09-16T13:15:34
True
False
False
/api/public/snipt/36906/
display-title-of-the-page
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> <span class="nx">the_title</span><span class="p">();</span> <span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
title, wordpress

JavaScript

grabs image alt or src and appends it to a title

1
2
3
4
$("img:not([title])").each(function() {
  		if($(this).attr("alt") != '') $(this).parent().attr("title", $(this).attr("alt"))
  		else $(this).parent().attr("title", $(this).attr("src"));
});
https://snipt.net/embed/13425d3d74263a8a54bb5cd09470d450/
https://snipt.net/raw/13425d3d74263a8a54bb5cd09470d450/
13425d3d74263a8a54bb5cd09470d450
js
JavaScript
4
2016-09-14T06:40:18
True
False
False
/api/public/snipt/13226/
grabs-image-alt-or-src-and-appends-it-to-a-title
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;img:not([title])&quot;</span><span class="p">).</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="k">if</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s2">&quot;alt&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="s1">&#39;&#39;</span><span class="p">)</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">parent</span><span class="p">().</span><span class="nx">attr</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">,</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s2">&quot;alt&quot;</span><span class="p">))</span> </span><span id="L-3"><a name="L-3"></a> <span class="k">else</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">parent</span><span class="p">().</span><span class="nx">attr</span><span class="p">(</span><span class="s2">&quot;title&quot;</span><span class="p">,</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s2">&quot;src&quot;</span><span class="p">));</span> </span><span id="L-4"><a name="L-4"></a><span class="p">});</span> </span></pre></div> </td></tr></table>
alt, img, jquery, src, title
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.