TYPO3 7.6.18 - Hide link text - typo3-7.6.x

I have the following condition for a link. If the linked page is hidden there will be no link. That's fine!
<f:if condition="{data_item.tx_mask_link}">
<f:link.typolink parameter="{data_item.tx_mask_link}">
<i class="fa fa-angle-double-right"></i>
</f:link.typolink>
</f:if>
Is it also possible to hide
<i class="fa fa-angle-double-right"></i>
by the condition if the linked page is hidden?

You can use {data.hidden} for check out whether page is hidden or not. Let me give you straight example:
<f:if condition="{data_item.tx_mask_link}">
<f:link.typolink parameter="{data_item.tx_mask_link}">
<f:if condition="{data.hidden}!=0">
<i class="fa fa-angle-double-right"></i>
</f:if>
</f:link.typolink>
</f:if>
Here, check basic stuff {data_item.tx_mask_link} then if {data.hidden} not hidden then shows icon
Greetings!

Related

How to show bookmark icon on view in Laravel 8

I am creating a bookmark system where users can bookmark a particular product. When I attempt to load the icon for a bookmarked item, it shows both the icon, i.e., before the bookmark icon and the bookmarked icon.
Here's a simple explanation.
[{"id":2,"bookmark_id":"HRTKB1607974280","user_id":"HCTK001606935187","document_id":"HRTKD1607941923","created_at":"2020-12-14T19:31:20.000000Z","updated_at":"2020-12-14T19:31:20.000000Z"},
{"id":3,"bookmark_id":"HRTKB1607974280","user_id":"HCTK001606935187","document_id":"HRTKD1607941923","created_at":"2020-12-14T19:31:20.000000Z","updated_at":"2020-12-14T19:31:20.000000Z"}]
Now in the Blade file, I am using the following code.
#foreach($documents as $data)
#foreach($bookmarks as $bookmark)
#if($data->document_id === $bookmark->document_id)
<li class="active-bookmark">
<a href="/add_bookmark/{{$data->document_id}}"
data-toggle="tooltip" data-placement="left"
title="Bookmark">
<i class="lar la-bookmark"></i>
</a>
</li>
#break
#else
<li>
<a href="/add_bookmark/{{$data->document_id}}"
data-toggle="tooltip" data-placement="left"
title="Bookmark">
<i class="lar la-bookmark"></i>
</a></li>
#endif
#endforeach
#endofforeach
But for some reason, this is happening.
Am I doing something wrong, or is there any easy way to do this?
You are iterating through that loop and will always output a icon until the true condition is met. What happens when the first iteration it isn't met, it has to iterate again and output another icon.
Assuming these are all Collections you can do this without looping the bookmarks:
#foreach ($documents as $document)
...
#if ($bookmarks->contains('document_id', $document->id))
// have the bookmark
#else
// add bookmark
#endif
...
#endforeach

Cypress Tool -- how to do click action on Show and Hide button, unable to do action on this button

i have a scenario like below with hide and show button
when i fill some data in input box action witll show me button else button is in hide mode
the below is the code , please suggest me solution how to run my automation code after entering code in input box
when button enabled mode -- with out text entering in input box
<button data-v-320fbb42= type="button" disabled="disabled" class="btn z-btn mr-1 btn-primary rounded-0 disabled" style="position: relative;"><div data-v-320fbb42= class="d-flex flex-row justify-content-center align-items-center">Save </div></button>
else
when button disabled mode -- after entering proper text in input box
<button data-v-d0c5d35c= type="button" class="btn z-btn mr-1 btn-primary rounded-0" style="position: relative;"><div data-v-d0c5d3c= class=d-flex flex-row justify-content-center align-items-center>
Save </div></button>
so i tried all the scenarios like below , but noting is working ,
cy.get('button').should('be.disabled').invoke('show').should('be.enabled').contains('Save').click()
cy.contains('Save').click({force: true})
cy.get('button', 'Save').should('be.disabled');
cy.contains('button', 'Save').click();
Thanks for your suggestion or help
Since your disable status is based on a class - I have found the next solution for validation in https://docs.cypress.io/api/commands/should.html#Value
cy.get('button', 'Save').should('have.class', 'disabled')
cy.input(inputSelector).type(text)
cy.get('button', 'Save').should('not.have.class', 'disabled')
And a solution for forcibly enabling it
$(selector).removeClass('disabled')
cy.get('button', 'Save').should('not.have.class', 'disabled')

How to properly get the value contained inside a section using XPath?

having the following HTML (snippet grabbed from the web page I wanted to scrape):
<div class="ulListContainer">
<section class="stockUpdater">
<ul class="column4">
<li>
<img src="1.png" alt="">
<strong>
Buy*
</strong>
<strong>
Sell*
</strong>
</li>
<li>
<header>
$USD
</header>
<span class="">
20.90
</span>
<span class="">
23.15
</span>
</li>
</ul>
<ul>...</ul>
</section>
</div>
how do I get the 2nd li 1st span value using XPath? The result should be 20.90.
I have tried the following //div[#class="ulListContainer"]/section/ul[1]/li[2]/span[1] but I am not getting any values. I must said this is being used from a Google Sheet and using the function IMPORTXML (not sure what version of XPath it does uses) can I get some help?
Update
Apparently Google Sheets does not support such "complex" XPath expression since it seems to work fine:
Update 1
As requested I've shared the Google Sheet I am using to test this, here is the link
What you need is :
=IMPORTXML(A1;"//li[contains(text(),'USD')]/span[1]")
Removing section from your original XPath will work too :
=IMPORTXML(A1;"//div[#class='ulListContainer']/ul[1]/li[2]/span[1]")
Try this:
=IMPORTXML("URL","//span[1]")
Change URL to the actual website link/URL

Thymeleaf th:onclick event - calling confirm function

I am new to Thymeleaf. Recently I stumbled in the following situation. Here is a piece of my Thymeleaf html page:
<!-- an delete button link -->
<a th:href="#{/employees/delete(employeeId=${tempEmployee.emplId},firstName=${tempEmployee.firstName},lastName=${tempEmployee.lastName})}"
class="btn btn-danger btn-sm py-1 "
th:onclick="if(!(confirm('Are you sure you want to delete this employee ?') )) return false" >
Delete
</a>
This code works fine as intended. However I want to add employee name as part of the confirmation. Here is the code:
<!-- an delete button link -->
<a th:href="#{/employees/delete(employeeId=${tempEmployee.emplId},firstName=${tempEmployee.firstName},lastName=${tempEmployee.lastName})}"
class="btn btn-danger btn-sm py-1 "
th:onclick="if(!(confirm('Are you sure you want to delete this employee ' + '\'+${tempEmployee.firstName}+\'' +'?' ) )) return false" >
Delete
</a>
Unfortunately the result is:
Are you sure you want to delete this employee
'+${tempEmployee.firstName}+'.
Looks like Thymeleaf does not recognize ${tempEmployee.firstName}. It has no problem with it in th:href tag but does not like it in th:onclick.
I would appreciate if somebody can turn me into the right direction.
Not sure exactly what the problem is (though it may be related to onclick vs th:onclick. Regardless, I think a format more like this will work (with some added benefits like no JavaScript injection).
<!-- an delete button link -->
<a
th:href="#{/employees/delete(employeeId=${tempEmployee.emplId},firstName=${tempEmployee.firstName},lastName=${tempEmployee.lastName})}"
class="btn btn-danger btn-sm py-1 "
th:data-confirm-delete="|Are you sure you want to delete this employee ${tempEmployee.firstName}?|"
onclick="if (!confirm(this.getAttribute('data-confirm-delete'))) return false"
>
Delete
</a>
(Notice I'm using onlick and not th:onclick.
Instead of this line in above code ---onclick="if (!confirm(this.getAttribute('data-confirm-delete'))) return false">
You can write as:
onclick="return confirm(this.getAttribute('data-confirm-delete'))"

How to simulate click in span using Mechanize Ruby?

I have a webpage with list of pages:
<div class="pager">
<span class="current_page">1</span>
<span class="page" samo:page="2">2</span>
<span class="page" samo:page="3">3</span>
<span class="page" samo:page="4">4</span>
<span class="page" samo:page="5">5</span>
<span class="page" samo:page="6">6</span>
<span class="page" samo:page="7">7</span>
<span class="page" samo:page="8">8</span>
<span class="page" samo:page="9">9</span>
<span class="page" samo:page="10">10</span>
<span class="page" samo:page="11">11</span>
</div>
How can I click on the span using mechanize?
According to this ASCIIcasts you can perform searches and findings:
There are two methods on the page object that we can use to extract
elements from a page using Nokogiri. The first of these is called at
and will return a single element that matches a selector.
agent.page.at(".edit_item")
The second method is search. This is similar, but returns an array of
all of the elements that match.
agent.page.search(".edit_item")
http://asciicasts.com/episodes/191-mechanize
So doing something like:
agent.page.at(".page")
Will return the array of spans. And then you will be able to work with them and just do the #click action.
EDITED:
As long as the span is a non interactive element, and click is a Link action, you will have to find a workaround:
How to click link in Mechanize and Nokogiri?

Resources