i am new to concrete 5, i search alot for theming of Menu (i.e: sub menu's) navigation with image icon and description but not found any related material. i have the following Html:
<div class="menu">
<ul>
<li><span>Hem</span></li>
<ul>
<li><span>New</span><img href="images/first.jpg" /><span class='short-description'>some description</span></li>
<li><span>Nice</span></li>
</ul>
<li><span>Om oss</span></li>
<ul>
<li><span>Om Shine</span><img href="images/second.jpg" /><span class='short-description'>some description</span></li>
<li><span>Uom</span></li>
<li><span>Opasd</span><img href="images/third.jpg" /><span class='short-description'>some description</span></li>
<li><span>Hem</span></li>
</ul>
<li><span>Tjänster</span></li>
<li><span>Referenser</span></li>
<li><span> Kontakt</span></li>
</ul>
</div>
So how i can theme for this in concrete 5. or use like.
<div id="headerNav">
<?php
$a = new Area('Header Nav');
$a->display($c);
?>
</div>
Any idea about it, that how to theme for this in concrete 5 for sub menus with description and image icon.... Thanx.
Open file concrete\concrete\blocks\autonav, and changed line
if ($c->getCollectionID() == $_c->getCollectionID()) {
echo('<li class="nav-selected nav-path-selected"><a class="nav-selected nav-path-selected" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
}
Apply your active class in " tag like
if ($c->getCollectionID() == $_c->getCollectionID()) {
echo('<li class="nav-selected nav-path-selected"><a class="active" ' . $target . ' href="' . $pageLink . '">' . $ni->getName() . '</a>');
}
Related
On a page I need to scrape (with node.js and cheerio), I have this pattern:
<h2>
<span id="2015"></span>
<span class="ignore-me"></span>
</h2>
<div>
<ol>
<li>
<a title="TITLE1" href="HREF1"></a>
<a class="image" title="ignore-me-1" href="ignore-me-1"></a>
</li>
...
<li>
<a title="TITLE2" href="HREF2"></a>
<a class="image" title="ignore-me-2" href="ignore-me-2"></a>
</li>
</ol>
</div>
I would like to extract a list with TITLEs an HREFs.
I am trying something like this:
$('h2 > span[id="2015"]').next('ol > li > a').each(function(index, element) {
console.log('title:', element.attr('title'), 'href:', element.attr('href'));
});
without success (each loop is never entered...).
Any suggestion?
The ol element isn't actually the next element of span#2015. The ol element is inside a div which is the next element of h2. The right tree traversal is :
$('h2 > span[id="2015"]')
.parent()
.next('div')
.find('ol > li > a:not([class])')
.each(function() {
var $el = $(this);
console.log('title:', $el.attr('title'), 'href:', $el.attr('href'));
});
The h2 tag does not have an ID, thus your selector finds no results, nothing to loop over.
You could easily do it by looping anchor tags.
$("a").each(function(i, e) {
if (e.attr('title') && e.attr('href')) console.log("... stuff ...");
});
Or you can give your h2 an id, or remove the id from your selector. Many ways to loop.
When using an asset publisher, you can change Display Settings in the asset publisher configuration panel. If you select the Abstracts display template, a new option will be available for you (Abstract Length). How can I add an option like that to my Application Display Templates (ADT) ?
Example for the Abstracts template :
Example for my custom template (Abstract Length not available):
You can use substring in velocity code written inside ADT built for news asset publisher, check below code to display 100 character only of about us page
#if (!$entries.isEmpty())
<div class="news">
#foreach ($entry in $entries)
#set($renderer = $entry.getAssetRenderer() )
#set($className = $renderer.getClassName() )
#if( $className == "com.liferay.portlet.journal.model.JournalArticle" )
#set( $journalArticle = $renderer.getArticle() )
#set( $document = $saxReaderUtil.read($journalArticle.getContent()) )
#set( $rootElement = $document.getRootElement() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[#name='country-portal-image']") )
#set( $countryPortalImage = $xPathSelector.selectSingleNode($rootElement).getStringValue() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[#name='country-portal-title']") )
#set( $countryPortalTitle = $xPathSelector.selectSingleNode($rootElement).getStringValue() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[#name='country-flag-icon']") )
#set( $countryFlagIcon = $xPathSelector.selectSingleNode($rootElement).getStringValue() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[#name='country-portal-about-us']") )
#set( $countryPortalAboutUs = $xPathSelector.selectSingleNode($rootElement).getStringValue().substring(0,100) )
#set( $link = $renderer.getURLViewInContext($renderRequest, $renderResponse, '') )
#set( $viewURL = $assetPublisherHelper.getAssetViewURL($renderRequest, $renderResponse, $entry))
#set($news-summary =$entry.getSummary($locale))
#set($date = $dateTool.format("dd/MM/yyyy hh:mm:ss", $dateTool.toDate( "EEE, dd MMM yyyy hh:mm:ss Z" , $entry.getPublishDate())))
<div class="new">
<h1 class="title">$entry.getTitle($locale)</h1>
$date
<img src="$countryFlagIcon"/>
<img src="$countryPortalImage"/>
<h3 class="sub-title">$countryPortalAboutUs</h3>
<p class="read-more">
Read More
</p>
</div>
#end
#end
</div>
#end
You can create JSP hook to customize Asset Publisher configuration.
The original configuration is rendered by /html/portlet/asset_publisher/configuration.portal.jsp.
In your hook, you can include the original jsp and then add your own preferences.
Example:
<%-- Include the original Asset Publisher configuration JSP. --%>
<%#include file="/html/portlet/asset_publisher/configuration.portal.jsp"%>
<%-- Read current value from portlet preferences. --%>
<% String abstractLength = portletPreferences.getValue("abstractLength", "100"); %>
<%-- Hidden div with custom input fields. --%>
<div id="customPreferences" style="display: none;">
<aui:fieldset label="fieldset.abstractLength">
<aui:input name="abstractLength" label="abstractLength" value="<%= abstractLength %>">
<aui:validator name="number"/>
<aui:validator name="min">1</aui:validator>
</aui:input>
</aui:fieldset>
</div>
<%-- JS code to place custom preferences at the end of Display Settings tab. --%>
<%-- It uses jQuery, but it's not a requirement. --%>
<script>
$(document).ready(function () {
// find div with custom preferences
var $customPreferences = $("#customPreferences");
// find the last fieldset on Display Settings tab
var displaySettingsLastFieldset = $(".nav-tabs:eq(1)").siblings("div:eq(1)").children().filter("fieldset").last();
// insert custom preferences after the last fieldset on Display Settings tab
$customPreferences.insertAfter(displaySettingsLastFieldset);
// show custom preferences
$customPreferences.show();
});
</script>
It is a good approach to extend the original JSPs - ie. include the original and then make the customization. This way, there's a good chance of a painless update to next Liferay versions.
For general guidelines on how to implement JSP hooks, see Liferay Developer's Guide.
You can get a list of all the available portletPreference values available to the asset publisher ADT using:
<#list portletPreferences?keys as prop >
<li>
${prop}
</li>
</#list>
So, for your example, you could get the abstract length value set by the user using:
abstractLength: ${portletPreferences.abstractLength[0]}
best way if you creating your own ADT then manage content length in ADT instead of unnecessarily hooking of AP jsp.
here is a input code:
$str='
<div class="_53d _53q">Not necessary data</div>
<div class="tagWrapper">
<i style="background-image: url(https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-ash4/p206x206/401581_10201210435645736_1028078736_n.jpg);" class="uiMediaThumbImg"></i>
<div class="taggerOverlay hidden_elem"><div class="left blackwash"></div></div>
</div>
<div class="_53d _53q">Not necessary data</div>
<div class="_53d _53q">Not necessary data</div>
<div class="tagWrapper">
<i style="background-image: url(https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash3/p206x206/486115_10200477972538937_146909394_n.jpg);" class="uiMediaThumbImg"></i>
<div class="taggerOverlay hidden_elem"><div class="left blackwash"></div></div>
</div>
<div class="_53d _53q">Not necessary data</div>
';
Now i want the output as :
Array
(
[0] => https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-ash4/p206x206/401581_10201210435645736_1028078736_n.jpg
[1] => https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash3/p206x206/486115_10200477972538937_146909394_n.jpg
)
I want to get all of the images links in-between the " <div class="tagWrapper"> <i " attributes and discards all of the other contents. Please help me to give a php code.
You should use DomDocument to parse html.
You can improve this code by adding an extra level of searching over the <i> elements, but I thought the <i> tag was uncommon enough.
Once inside the style property, I used string parsing. It should be improved to be more versatile, but this should get you a lot closer to your goal.
$arr = array();
$dom = new DOMDocument;
$dom->loadHTML($str);
foreach ($dom->getElementsByTagName('i') as $node) {
if($node->hasAttribute('style')) {
$nodes = explode(":",trim($node->getAttribute('style')), 2);
if(trim($nodes[0]) === 'background-image') {
$pos = strpos(trim($nodes[1]), "url");
if($pos !== false) {
$arr[] = substr(trim($nodes[1]), 4, -2);
}
}
}
}
I am new to PHP, Javascript and HTML. So maybe I'm missing something obvious but, I can't for the life of me figure out what is wrong with my code. I am trying to use Paul Irish's Infinite Scroll with a PHP file that has an anchor point that links back to itself with different GET values. The problem is that Anything I do gives me this error:
Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag.
I am at my wits end and desperately need someones help because I need this done by January 20th. It's going to be a birthday gift for someone I know.
Here is my code:
index.php (Code Snippet)
<div id="content-container" class="container-fluid" style="padding:0px;overflow:hidden;">
<div class="row-fluid full">
<div class="span12 full" style="overflow:scroll;position:relative;">
<div id="media-palette">
<?php
include('content.php');
?>
</div>
</div>
</div>
</div>
script.js (Code Snippet)
$("#media-palette").infinitescroll({
navSelector:"#next",
nextSelector:"#media-palette a#next:last",
itemSelector:".media-content",
bufferPx:50,
debug: true,
}, function(newElements) {
$("#media-palette").masonry('append', newElements,true);
});
content.php
(It is worth noting that the images found in this file are for testing purposes and the final PHP file will load images from a database.)
<?php
require('dbconnect.php');
$startIndex = $_GET['start'];
$endIndex = $_GET['end'];
$nextStartIndex = $endIndex-1;
$nextEndIndex = $endIndex-10;
?>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<?php
$files = scandir("images");
if ($files) {
$length = count($files);
static $allowedExts = array("jpg", "jpeg", "gif", "png");
for ($i = 0; $i < $length; $i++) {
$extension = end(explode(".", $files[$i]));
$extension = strtolower($extension);
if (in_array($extension,$allowedExts)) {
$rand = rand(0,10);
if (!$rand) echo "<img class='media-content medium' src='images/".$files[$i]."'/>";
else echo "<img class='media-content small' src='images/".$files[$i]."'/>";
}
}
}
echo '<a id="next" href="content.php?start='.$nextStartIndex.'&end='.$nextEndIndex.'"></a>';
?>
</body>
in wordpress, I am fetching menu using wp_nav_menu() function. It will list menus in following form.
<ul>
<li>AA</li>
<li>BB</li>
<li>CC</li>
</ul>
I want to add one more property to tag. I want it in following form.
<a href="url" name="aa">AA</li>
<a href="url" name="bb">BB</li>
<a href="url" name="cc">CC</li>
name property should have value equal to link text but in lower case. i.e. is menu text is AA then name property should have aa
You can do this with Wordpress Walkers. They can be a bit tricky at first, but very powerful. This is a rough implementation, you would probably need to improve it.
First, you extend the Walker_Nav_Menu to your needs:
class my_nav_menu extends Walker_Nav_Menu
{
function start_el(&$output, $item, $depth, $args)
{
$output .= '<li><a href="' . get_post_link($item->ID) . '" name="' . $item->post_name .'" >';
$output .= apply_filters( 'the_title', $item->post_title, $item->ID ) ;
$output .= '</a></li>';
}
}
Then you pass an instance of your class to wp_nav_menu:
wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' , 'walker' => new my_nav_menu() ) );
This will output menu elements like this:
<li><a name="test-page" href="http://mydomain.foo/?page_id=1">Test Page</a></li>