facebook comment system using smarty and prestashop - api

I'm trying to add some comments box to a specific page of my website
but I met some trouble
using smarty I've seen in the documentation that in order to get the current url we should use that synthax {$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}
that's actualy what I did putting that code in my tpl.
{literal}
<div id="fcbcfooter"><div data-href="http://{$smarty.server.HTTP_HOST}
{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" class="fb-
comments" data-width="500px;" data-num-posts="10" data-
colorscheme="light"></div>
{/literal}
The trouble I have is that it return to me that message
href URL is not properly formatted
The code for getting url does not seems to be interpreted in the source code.
anykind of help will be much appreciated.

You are missing a closing </div> at the end of your code block right before the {/literal} tag.
{literal}
<div id="fcbcfooter">
<div data-href="http://{/literal}{$smarty.server.HTTP_HOST}
{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}{literal}" class="fb-comments" data-width="500px;" data-num-posts="10" data-colorscheme="light"></div>
</div>
{/literal}

Related

How to interpolate nuxt-link's `to` prop?

I've been searching this for a while but can't seem to get it right. I have a basic Nuxt project with the following directory structure (ignore the fun.vue) :
The idea is to be able to navigate to a single post with paths like http://localhost:3000/posts/1
This works, if I manually go to .../posts/1 I get my page defined in _id.vue.
The problem is that, in my index page, I cannot get <NuxtLink> to go to single post pages. I have a basic v-for looping over my fetched posts array, like so:
<template>
<div>
<div v-for="post in posts" :key="post.id">
{{ post.title }}
<NuxtLink to="`posts/${post.id}`">Link to post</NuxtLink>
</div>
</div>
</template>
I would expect, upon clicking on the 2nd post's link for example, to navigate to posts/2, but instead I get /%60posts/$%7Bpost.id%7D%60. Why isn't the template string converted normally? I've also tried using a computed value with no success, and the Nuxt Routing docs haven't been of much help.
Highly appreciate any help regarding this.
You forgot the semicolon:
:to="`/posts/${post.id}`"
or even better
:to="{ name: 'post-id' }" // post-id or basically the name you gave to your component
As shown here: https://router.vuejs.org/api/#router-link-props
You can use something like this
the ":" in front of it will make it dynamic and you can use template literals
in between those double quotes
<NuxtLink :to="`posts/${post.id}`">Link to post</NuxtLink>
I tried your code in my development environment. You also may forgot to add "/" in front of "posts":
<NuxtLink :to="`/posts/${post.id}`">Link to post</NuxtLink>
If you put your code without "/" in a Nuxt "layout", it adds "posts" iteratively to your "URL" and makes the destination wrong:
http://localhost:3000/posts/posts/2
This happens when you click on post 1 and after to post 2.

Selenium cannot find element: directly under div

I am trying to use xpath to find a specific text from a page. Selenium can not find this exact text.
Here is the code I am trying with:
searchresult = self.driver.find_element_by_xpath("//*[contains(text(), 'Sorry, we could not find the book you were looking for.')]")
Here is the HTML I am working on:
<div style="width:100%;padding: 20px;">
<div class="searchbox">
</div>
<div class="vert-spacing-15"></div>
Sorry, we could not find the book you were looking for. Please try
searching for something else.
</div>
Try it like:
//*[contains(., 'Sorry, we could not find the book you were looking for.')]
Why? Because text() will only match the text before the first child element.

Unable to retrieve the text inside the div tag even when the tag is identified

I am trying to retrieve the text embedded inside the div tag. Partial html code is given below. I consulted the other existing answers, but the tag is located successfully but the text is coming back as empty string.My purpose is to retrieve the string between the 'div' tag as "You entered an invalid username or password, please try again."
I used the xpath
//div[#class='login-card js-login-card']/div[#role='alert']/div[2]
I used the css
.alert__heading.js-alert--error-text
This only getting back the tag name as div, but the text as an empty string.
Any ideas or corrections?
<div class="login-card js-login-card">
<div class="login-page__alert alert alert--error tt js-alert--error" role="alert">
<div class="alert__icon">
<div class="alert__heading js-alert--error-text">You entered an invalid username or password, please try again. </div>
</div>
<div id="cmePageWrapper" class="page-wrapper page-wrapper--card"> </div>
Try following xpath, as the required div tag is child node of div with class 'alert__icon':
//div[#class='login-card js-login-card']/div[#role='alert']/div[1]/div
Let me know, if it works for you.
Maybe you wanna try this
div[class*="error-text"]
If it didn't work try to get text by executing javascript code using this
$$( "div[class*="error-text"]" ).text() OR .val()/.html()
Good luck !
You could use contains with xpath, something like //div[contains(#class, 'error-text' ) ], using findelement will retrieve first element match the criteria. If it still returns empty, it means that the page might have more than one element which match the criteria

Xpath Selenium trouble

Can anyone help me? i tried using Firepath for a correct Xpath however the code it gives me is incorrect in my eyes. First line in the examples, is the provided one.
.//*[#id='content']/div/div/div[1]/h2/span
<div id="content" class="article">
<h1>News</h1>
<div>
<div>
<div class="summary">
<h2>
<span>9</span>
// this should be the correct xpath i think
_driver.findElement(By.xpath("//*div[#id='content']/div/span.getText()"));
Here i want check if the text in between is greater or equal to 1
and the other is:
.//*[#id='content']/div/div/div[3]
<div id="content" class="article">
<h1>News</h1>
<div>
<div>
<div class="summary">
<div class="form fancy">
<div class="common results">
Here i want to check if the div class common results has been made, 1 item equals 1 common results
For retrieving span text you can use this
String spanText=driver.findElement(By.xpath("//div[#id='content']/div/div/div/h2/span")).getText();
System.out.println(spanText);
From the second question I am not so much clear.You can get class name like this, Please explain me if its not your solution
String className=driver.findElement(By.xpath("//*[#id='content']/div/div/div/div/div")).getAttribute("class");
System.out.println(className);
I would suggest you making usage of:
//div[#id='content']/div/div/div/h2/span/text()
Note: the html code you shared was not well formed. I would suggest you to test in advance the code and the xpath with http://www.xpathtester.com/xpath (to fix the code) and http://codebeautify.org/Xpath-Tester (to test your xpath)

selenium-how to click on link which is nested inside div

I have div and hyperlink like this:
<div id="food-add-actions" class="actions food_dialog fd_food_dialog_s-fndds2-f41210000">
<div class="right">
<span></span><span>Add to Food Log</span>
<span></span><span>Edit</span>
</div>
</div>
how can i click on this Edit hyperlink?
i tried below but it did not worked for me
driver.findElement(By.className("edit button")).click();
The problem you actually have is that you have a space in your By.className.
There is a question with a similar problem here.
webdriver classname with space using java
You should be able to select it with a By.css selector, such as.
By.css('.right a.button')