How can i have a link field in a content type display a default text when the field is empty - drupal-7

How can i have a link field in a content type display a default text when the field is empty.
For now i have a field as a link - and the link is set to have a static title. This Works fine.
But i'd like to display a default title if the field is empty with no link (but still rendered as a link/button).
It's not a view - so i can't use "rewrite output if empty".
I'm a newbee to drupal - so please help
This shows what I've got so far:
http://1fb72c32b5e90467b795f388746f7501b3ad8021.web9.temporaryurl.org/tmp/link2.PNG
When the link field is empty the button doesn't show. Instead of not showing when empty I'd like it to show someting like this as default:
http://1fb72c32b5e90467b795f388746f7501b3ad8021.web9.temporaryurl.org/tmp/link3.PNG (the button "Bestil på tlf...")

By simply using Link module, i don't think this is possible. But, follow below steps in your environment and i think you might achieve the goal:
Make custom template file for the page (i think, its product details page)
In that template file, check whether the link is empty or not
If link is not empty, show the link. If link is empty, show your custom HTML.

Related

Turn custom link to formula field

I have created a custom link for a custom object and it works. But it's not controlled by FLS so I have to move to Formula field.
What should I do to turn it to a formula field?
Here's my custom link codes:
https://sanofi-pharmachina--dev1.cs5.my salesforce.com/a0C?rlid=01I7F000002B91V&id={Account_Plan_vod__r.Account.ID!}
a0C is object code
01I7F000002B91V is object ID
{Account_Plan_vod__r.Account.ID!}
How should I turn this to a formula field with proper codes?
Thanks!
The HYPERLINK formula, this should work. It shows your link as a clickable url on the detail page of a record:
HYPERLINK("/a0C?rlid=01I7F000002B91V&id=" & Account_Plan_vod__r.Account.ID,"Link Text here")

"How to fix 'at org.openqa.selenium.support.ui.Select.<init>' error in selenium"

I have created the object of Select in selenium to handle dropdown . Also have included the associated packages. Yet the dropdown is not getting selected. Kindly help!
Select select = new Select(driver.findElement(By.xpath("/html[1]/body[1]/div[1]/div[1]/header[1]/div[3]/div[1]/div[1]/div[6]/ul[1]/li[1]/a[1]")));
select.selectByValue("Blouses");
I am recieving the following error "at org.openqa.selenium.support.ui.Select.(Select.java:48)";
Alongwith a note when i hover over Select -
org.openqa.selenium.support.ui.Select
Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.
As far as I can see your XPath expression ends with a which indicates <a> HTML tag which in its turn stands for a hyperlink
In order to be able to use Select class you need to pass to it's constructor a WebElement instance which will point to a <select> HTML tag.
If there is no <select> elements in your page source code - it means that the dropdown is being generated by means of CSS and JavaScript therefore you just need to click the link with the Blouses text which in its turn can be as simple as:
driver.findElementByLinkText("Blouses").click()
If you still want to use XPath - be aware that you can make it a lot shorter, readable and reliable: limit your search scope to hyperlinks only like //a and utilise text() XPath function to match only "interesting" links, the expression which will click the link with Blouses text would be something like:
driver.findElementByXPath("//a[text()='Blouses']").click();

Nested layouts in admin-on-rest

I've started investigating admin-on-rest. It works fine for 'flat' REST-endpoints, e.g.:
/posts/
/users/
etc.
But how do I implement nesting? I mean if I click on some post-entry in 'posts' table - I want not the actual post to be opened in a <Show> view, but a list of it's comments (fetched from URL /{postId}/comments)? And I need also to keep the navigation functionality (some back-arrow button or hierarchy in the header to return to previous page).
Is this even possible with admin-or-rest?
If you want to show a list of comments for a post, use the <ReferenceField>. You can see an example in the demo: https://marmelab.com/admin-on-rest-demo/#/customers/77 (click on the "orders" and "reviews" tabs to see an embedded datagrid).
If you want to link to a filtered list of comments from the post list, you'll have to create a custom button component. Once again, you can find an example in the demo: https://github.com/marmelab/admin-on-rest-demo/blob/master/src/segments/LinkToRelatedCustomers.js

IBM WCM Plugin:RequestAttribute is not working, when used on published site ( only preview is working)

I've made a menu component to create tabs which contains rendered results from another menu component.
The internal component is using Location/Site Areas (set by Query string) as a criteria and in the main component I use [Plugin:RequestAttribute(...)] to set the Site Area I want the content from in specific tab. In order to do so, I put the internal component inside [InContext(...)][/InContext] tags - in this case Result design code of the main component is:
title="[Property field="title"]">
[Plugin:RequestAttribute key="year" mode="set" value="[Property field='title']"]
[InContext context="autofill"]
[Component name="omantel_en/investors/financial snapshots/financial statement menu" startPage="" resultsPerPage=""]
[/InContext]
</div>
The header ends with <div class="tab selected", while separator is set as <div class="tab" which in the end construct a valid HTML structure (of that I'm sure).
Tabbing is held by javascript I put in the beggining of header and works fine.
Everything works fine while using Preview option - content is generated properly, I can even use Preview on site I actually want the component to be used on and this will give me desired result.
The problem occurs when I put the main menu component tag in published Article. Then it shows only tabs, without any content from the inner component. It looks as if the [Plugin:RequestAttribute(...)] tag that is used as substitute for Query string stops working.
I already tried to put the main menu component tag (in the actual Article) inside [InContext(...)][/InContext](with all of possible options) but it gave no good result. I'm kind of new in using IBM websphere~.
Any suggestions?
Actually it was a problem with Libraries - I simply put wanted content in single library and now it works fine.

Set focus on autocomplete field

I have a form that has some fields.
One field is autocomplete
.
The field is filled with information from a table
$f->addField('autocomplete','idfield','Field')->setValueList( $this->api->db->dsql()
->table('items')->field('id,name')->do_getAssoc() );
I'm trying to set the focus on that field when the page loads.
I have did this
On top of the page
$p->js()->_load('seteo_foco');
And then
seteo_foco.js
$(function(){
$("select:first").focus();
})
But this does not work.
Anybody can help ?
Thanks
Try TRUE like
$this->js(true)->_load('seteo_foco'); to load js file.
But in your js code your selector is incorrect. You need to specify you unique field. I'd use something like $form->getElement('field_name')->js(true)->focus(); on the page after the form has been initialized.

Resources