I would like to know how we can add a proper search result (see the linked picture) on Google search results. Is there a minimum visitor count required or something similar required?
According to this article, you need this mark up on your site:
<script type="application/ld+json">
{
“#context”: “http://schema.org”
“#type”: “WebSite”
“url”: “https://www.example.com/”,
“potentialAction”: {
“#type”: “SearchAction”,
“target”: “https://query.example.com/search?q={search_term_string}”,
“query-input”: “required name=search_term_string”
}
}
</script>
With url and target whatever they need to be for your site.
Related
Not sure how to label the title of this question. I have a snippet of re-usable content with a Subscribe Icon + Social Icons. This snippet is used in almost every page on the site through a repeater.
What I want to do is to attach the CurrentDocument.DocumentName to the Subscribe Icon in order to know which page people came from, something like this:
Subscribe However, looks like that doesn't work. This string shows in the address bar when click on the link: www.domain.com/subscribe?p={%%20CurrentDocument.DocumentNamePath%20|(user)|(hash)34ce5eaa55a6a6ad89...%} I figure because CurrentDocument is actually referring to the snippet itself, not the real current page displaying in the browser. Could you help?
Is your repeater transformation aspx? If so, use <%# %>, so <%# CurrentDocument.DocumentName %>
If this is an ASCX transformation it is like a web user control, so you can call C# methods, try this
<%# CMS.MacroEngine.MacroResolver.Resolve("{%CurrentDocument.DocumentName#%}")%>
Or you can do linke in this in ACSX transformation:
<script runat="server">
string test = "";
protected override void OnInit(EventArgs e)
{
test = CMS.MacroEngine.MacroResolver.Resolve("{%CurrentDocument.DocumentName#%}");
}
</script>
<h1><%# test%></h1>
Consult MacroResolver class for other methods
P.S. Sorry I didnt check my answer in Kenitco for the frist time. Just make sure you calling MacroResolver from the right name space.
I want to integrate google search in website such way that whenever we search in google the search box should show like below image. we have used #context and schema and somewhere I found on google block of code is:
<script type="application/ld+json">
"#context": "http://schema.org",
"potentialAction":
{
"#type": "SearchAction",
"target": "http://www.WEBSITENAME.com/search?q={search_term}",
"query-input": "required name=search_term"
}
</script>
I got help from here.
http://searchenginewatch.com/sew/how-to/2431095/how-do-i-get-a-search-box-to-appear-in-my-site-s-search-results
Hope this will help you. Also It takes some time.
I want to add a meta tag in my each individual page of life ray. I am could only find meta tag with description which is in the SEO of the pages in Control panel.
<link rel="alternate" href="http://example.com/xyz/abc" hreflang="en-au" />
Please help me out with this. I am unable to find an answer to this.
The best and permanent way is to create custom theme (or modify default one) and add general meta-tags, javascript / css files (which you want to appear on each page of portal) through head section of theme's portal_normal.vm file. However, if you want to restrict these tags for specific page(s) you can still do it through Velocity Objects like public / private layout, admin / user difference, current page name / URL, there are numerous options available.
If you are new to theme design, you can start with: Creating Liferay Themes
The other possible and quick way is to add js / css dynamically using javascript / jQuery as following:
if you are using pure javascript:
window.onload = function(){
loadjscssfile("myscript.js", "js");
loadjscssfile("javascript.php", "js");
loadjscssfile("mystyle.css", "css");
}
Or you can use jQuery:
jQuery(function(){
loadjscssfile("myscript.js", "js");
loadjscssfile("javascript.php", "js");
loadjscssfile("mystyle.css", "css");
});
general method:
function loadjscssfile(filename, filetype){
if (filetype=="js"){
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
}
else if (filetype=="css"){
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", filename)
}
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref);
}
Reference: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
Add above code to the javascript section of the root of your pages.
Long time reader. First time asking questions. I've learnt a huge amount from this forum..
I am using an online database (Caspio.com) and have configured it to return search results. Basically my database has a field "Membership" which can have 3 levels - Basic, Pro and Premium. Depending on level of membership I need to display a different HTML code in my search results page.
I've tried both
a) Jquery's html() API
<div id="biz-name"></div>
<script type="text/javascript">
var membership = '[#field:Membership]';
if (membership == 'Basic')
{
$("#biz-name").html("[#field:Company_name]");
}
</script>
b) innerHTML
<div id="biz-name"></div>
<script type="text/javascript">
var membership = '[#field:Membership]';
if (membership == 'Basic')
{
document.getElementById('biz-name').innerHTML ='[#field:Company_name]';
}
</script>
In both cases, when the search returns multiple results, ONLY the 1st result's div is updated. However it has the value of the LAST result's Company_name.
Does anyone know how to tweak this to make it work on a per-result basis?
I would really appreciate the help.
I don't quite understand how you would like to show the results, but I think it's not good to use the same ID attribute for multiple elements.
Try to use class instead. Also, when you manipulate multiple results in such way I think you need to use the each() function.
$(".biz-name").each(function() { $(this).html("...") });
In Liferay I have used the asset publisher to publish news on my news page. I want to fetch the 3 top news from the page and embed it into another page. How can I do this? The page URL containing the news links looks like the following:
Liferay.Widget({ url: 'http://test.com/testnews/101_INSTANCE_f22'});
Liferay itself has a property where one can share an asset publsiher instance any where else on a site, but that is not exactly what I want. So any help or guidance is appreciated. Thanks.
If you want only links then you can set display style 'title-list' (this will take you to the article on the main news page).
if you want to open the link in another page, change asset link behavior to 'View in a specific portlet'.
You can change the look of asset publisher to whatever design you want. follow the path look & feel --> advanced styling --> Copy the portlet id. Now by using mozilla firefox pick the class,tags,etc. and write your css code. This will override the basic design. E.g.
#p_p_id_101_INSTANCE_8f5JPIxv8ml0_ .asset-abstract {
width: 25%;
float: left;
}
Is there a particular reason why you don't want to configure another AssetPublisher on the second page? You can just use the identical configuration, but limit the number of results shown to 3 - done.
Problem solved. Here is the solution with jQuery:
$.get('http://test.com/news/', function(data) {
var top3links = $(data).find('a:lt(3)');
$('#top3').html(top3links); // });