Wagtail: How to get a table of content of a page (StreamField) - wagtail

How can I create a table of content from my headings within a page?
I use StreamFields in my page and I would like to create a table of content based of the <h1>, <h2> and <h3> headings.

Related

No Option To Get Angular Smart Table State With Visible Columns

I'm just wondering if they have provided a options to make table columns show and hide as user preference and save it in table state and load it back when page refreshes.
ctrl.tableState()
upper code only brings the pagination,sorting and search objects as in current table state. How can i implement showing and hide table columns like in jquery Datatable and load it back from the table state object?
Decided to use Jquery Data Table instead with AngularJS ng-repeat

Hiding a Web Content Viewer JSR 286 Portlet if no content is found

I have configured a JSR 286 portlet on my portal page which points to a content item. The content item has an expiry date. Once the content expires the user sees default warning message saying no content found for the selected site area.
I want this portlet should not be rendered if there is no content in the selected site area instead of showing a warning.
Use a Menu Component that is set to only display 1 item for your portlet. Then create a second content item that has a Presentation Template that just says something like this:
<div class="emptyPortlet" style="display:none;"> This is an empty template. </div>
*if you don't want to declare the style inside the tag, you could also specify .emptyPortlet { display: none;} inside your CSS file.
Publish this before your other item and then set the Menu Component to display based on Publish Date. This way, when you create another item that you want to display (which uses a different Presentation Template), it will have a more recent publish date and will be shown on the page. But, once that is expired, the only published item left to find will be this blank one, and with "display: none" it will essentially hide the entire portlet from the user.
You have a few options
Easiest would be to create a custom skin that shows or does not show depending on it's internal contents. just create your own skin to return nothing
Your other options include scraping it out of the response with a servlet filter or some other mechanism or stripping it from the page once you have started rendering

How can I dynamically add HTML div boxes via ng-repeat?

I wish to use ng-repeat tag for reading the product list in JSON.
Suppose if I have 10 products in JSON then it shall create 10 div boxes (Something similar to the e-commerce products page)
I am unable to create these div boxes via ng-repeat.
Can someone help me with any example ?
I wish to display something like this .
EDIT
I am not concerned about data here.
My question is that how can I add those rectangular div boxes as seen in the image attached in the question.
Supose in the controller you set a list of items to $scope.items, and every item has a name and a code.
<div ng-repeat="item in items">
<p>{{item.name}} - {{item.code}}<p>
</div>

Apply AngularJS directive when div is visible

I have added a custom directive in Angular JS. I have added one page in which I have 4 div tag. These 4 div tag are not displayed at once, but they are getting displayed in tabs, so on click of particular tab respective div gets displayed.
But when the page loads all div tag are loaded so directive is called when page is loaded. But what I want to achieve is when the div tag gets visible (on click of tab) it should execute that directive.
Is there a way to achieve this ?
Thanks.
-- Update - 1
let me explain my problem with more details ..
I am displaying tabs using boot-strap data-toggle="tab", so when I select particular tab it displays that tab content.. but on click of tab bootstrap is showing / hiding tabs by applying css.
<a href="!#tab_1" data-toggle="tab">
<a href="!#tab_2" data-toggle="tab">
<a href="!#tab_3" data-toggle="tab">
<div class="tab-pane fade" id="tab_1">
... some content
</div>
<div class="tab-pane fade" id="tab_2">
<table>
<tr ng-repeat="user in userList">
<td>{{user.name}}</td>
<td>{{user.contact}}</td>
View
Edit
</tr>
</table>
</div>
<div class="tab-pane fade" id="tab_3">
... some content
</div>
<new-user-modal username="name"></new-user-modal>
so, now when i load page by default tab_1 is selected / active, but other tabs are already loaded but are hidden. Here <new-user-modal> is a custom directive, which points to a template using templateUrl ../../newUserTemplate.html, which has div with id new_user_modal.
So when I select tab_2, i see list of users, all user row will have View action, and when i click on View action, it displays pop-up using newUserTemplate.html template. I have implemented a custom directive to display all fields in form as read-only, so when user clicks on View action it should display all fields in read only mode.
template (../../newUserTemplate.html) div with id new_user_modal has this custom directive read-only added to it, so when i load page first time when by default tab_1 is selected that time its calling read-only custom directive.
But I want it to be called when action is clicked, so based on it i can open modal either in read-only or edit mode.
let me know if you need any other details..
-- Update-2
basically I have created two directives one is new-user-modal and other is read-only.
First directive is to load user details in a modal(popup) which as i explained is getting generated using data-toggler=modal. This directive new-user-modal has template which is a form with user related fields, so when user clicks on any user records, this modal will be displayed with user information..
new-user-modal directive is pointing to template file ../newUserTemplate.html, where i have all user fields. In this template i have added my another custom directive read-only, so if user clicks on view user action, it will open this modal in read only view means all form fields will be read only, and if user clicks on edit user action, same modal will open in edit mode.
But, as this modal is getting generated using bootstrap, this modal is already loaded when the page is loaded first time, but its hidden. So directive is getting called when page is loaded not when modal is shown ..
You could use ng-if for directives and check if the current tab is open. ng-if recompiles the directive from scratch only when the value is true, or in your case
Something like this:
<tabs>
<pane title="Tab1">
<directive ng-if="tab1.active"> </directive>
</pane>
<pane title="Tab2">
<directive ng-if="tab2.active"> </directive>
</pane>
</tabs>
Is this something you want? There is also another way using $compile but it's not so correct.

display civicrm image in drupal views

How to display an image stored in civicrm database in Drupal views?
I have a webform through which user registers and details are stored in civicrm db. I have created a view which displays the user data but when it comes to images it only displays URL of image. Is there a way to display image also
The civicrm image field is a url. To make it display as an image you will need to surround it with an <img> tag using the "rewrite" option in views.
In your view click on the field and check "Rewrite the output of this field"
Enter this text: <img src="[image_URL]" alt="Contact Image" style="max-width: 200px" />
The "alt" and "style" attributes are optional and you can set max-width to whatever you want (but if you omit it the images will all be the uploaded size).

Resources