Drupal hide comment form in initial page load - drupal-7

I'm using drupal 7 and want to hide my comment form for any content type to be hidden by default. I just need "Add comment" button, once i click on it, then it should render comment form. Is there any module / way to achieve this.

you could hide the comment form in CSS with something like
#comment-form{display:none;}
plus a selector specific for one content type if you want.
Then add a javascript in that page adding some code to your subtheme's page.tpl.php that is in your subthem's templates folder (if there is no such file copy it from te parent theme templates folder)
drupal_add_js('path_to_js_file/file.js');
And in the file.js you define the function to show/hide the comment form, i.e. to change the style of #comment-form to display:block;
Then you have to create the button and you can do this in several ways:
you can create a custom block with the code for the button, you can add it in the node.tpl.php template. You can add a custom field to the content type with Display Suite code field, or maybe other modules.
This is just one way to do it.

Related

Can I import/borrow a function specific to a Gutenberg core block into my custom block?

I have a custom Gutenberg block with a button, which right now is rendered by RichText. I want this button to be linkable, however, I don't like the rich text toolbar in this case because it allows the user to select partial text, add multiple links, etc. Instead I want the link picker to function like the Gutenberg core Button block (when you use the link picker in the toolbar, it automatically applies the link to the entire button, preventing the selection of partial text.)
In the edit.js of the Button block there is a function called URLPicker that does this (Github link). Is there a way I can use this?

Stylizing LWC radio list?

So right now I'm trying to build this radio list for the regions in LWC, the functionality works fine in that when you click on the regions it selects all the states below for that region.
https://i.stack.imgur.com/y2MM8.png
However, I want to stylize it so that it looks more proper. I'm a little confused how to do this using these components that LWC provides. Here's a mockup of what the regions should look like.
https://i.stack.imgur.com/A26PH.png
Here's what the HTML for it looks like.
https://i.stack.imgur.com/1vWcy.png
You can probably achieve this by using the grid system : https://www.lightningdesignsystem.com/utilities/grid/
We can achieve the same style by following a couple of steps:
Pass class to each lightning inputs to scope the styling.
Style radio controls having the passed class name.
save the file as .css and store in static resources.
Load style sheet in component by making use of loadStyle method from platformResourceLoader module.

Salesforce Custom field in Edit Page ONLY

I wanted to display a custom field as Read-Only on the Edit page ONLY of a custom object. This field should be hidden on the detail page. I tried wrapping the field in a section and display the section in Edit Page only(Page layout editor). That didn't work. I don't want to create a custom visual force page for the EDIT Page. Please suggest.
Thanks
Kumar
Unfortunately, there's no way to put a field on just edit or just detail. It's both or neither.
You have two options, custom Visualforce page as an Edit override is the easiest one, but if you want to leave the page layout editor as something useful to admins, there's also a very hacky option...
Create two record types, one that displays the field and one that doesn't. Create a new button that launches a Flow (with a return URL of the edit page for that object). The Flow should change the object's recordtype to the one that displays the field. Additionally, create a Process or trigger that changes the recordtype back to the one that does not display the trigger after you save the object.
I definitely recommend the VF page...

Tipsy +Views Tooltip is not working

I want to show Tooltip inside Views UI. I installed following two modules:-
Tipsy
Views Tooltip
I have following fields in the Views UI:-
Name[Visible]
Snaps[Visible]
Now add field "Global: Tooltip" inside Views UI. I gave a simple "Hello" in the "Tooltip text".
My requirement is to simply show the hello text as tooltip for snaps inside View.
Tipsy Configuration are as follows:-
Please let me know what am I doing wrong as tooltip is not being shown.
Try checking "child" under content class and check that your page output (use firebug or whatever) does not place the tooltip content class as a sibling (same level) as the tooltip class.

May I customize 'edit custom object records' page layout on SalesForce?

For example, to create or edit an object, when I want to add or change some value to one specific field, I need to refer another website to retrieve some info.In this way, may I add one button or link on the edit page?
The help link of SalesForce is here: https://help.salesforce.com/apex/htviewhelpdoc?id=co_edit.htm&language=en_US
Thanks.
Custom buttons and links don't display on new/edit page layouts so even if you'd make one, it will be visible only on detail view.
Not too invasive option would be to create a URL or text fied, set it's default value to your link, make sure it's displayed on the page but readonly. Haven't tried it but should work (you'll have to test it as somebody other than System Administrator because you'll bypass the readonly property of the page layout).
More invasive option would be to override the new and edit page layouts with Visualforce. More work but somewhat clean solution.
Really crazy option would be to embed a piece of Javascript into section header on the standard page layout or even into sidebar. It's an ugly hack but it works, I've used it for example to disable editing of Name field.
To use method #3:
create new section header, add something to the section (blank space is fine, you need something otherwise headers for blank sections aren't rendered), mark the section as visible on edit pages only.
Section name has limit of 80 characters but can contain code like <script>document.getElementById('Name').disabled = true;</script>. You need longer script though to somehow create an URL at runtime and append it somewhere on the page near your "special" field.
Upload a static resource with your script, then use this as the section header: <script src="filename.js" type="text/javascript"></script>
I'm not too proud of this hack and if you can - go with custom Visualforce new & edit page. It's quick & dirty, probably should be used only when you're not allowed to override pages.. but it works.

Resources