Active Admin pagination - pagination

Active Admin's pagination on index pages is great, but we are trying to allow the user to type in the desired page number (in addition to the clickable page buttons).
Their desire is to have a prompt like "Enter Page Number:" and an input box where they can type in the desired page number.
Anyone done this already, or have ideas on how to proceed?

You can create a custom sidebar section like this:
sidebar :jump_to_page do
input :page_number
input type: :submit
end
Then add this to you active_admin.js.coffee file:
$ ->
$("#page_number_submit").on 'click', (e) ->
page_number = $("#page_number").val()
if window.location.search.indexOf("page=") > 0
window.location.search = window.location.search.replace(/page=\d*/, "page=#{page_number}")
else if window.location.search.indexOf("?") == 0
window.location.search = window.location.search + "&page=#{page_number}"
else
window.location.search = "page=#{page_number}"

Related

Setting a text view to blank text after being toggled

I have a text view that is clickable. Every time the user clicks the text box, it will display a string. When they click it again, the box will become blank. I have this so far:
textToggle.setOnClickListener {
textToggle.text = "Hello"
}
I have seen some examples where the person did an override on onClick. Would that be the case for here too, or is there a simpler way that I'm not seeing?
Just check the length of the text when you click on it.
textToggle.setOnClickListener {
if(textToggle.text.length > 0) textToggle.text = ""
else textToggle.text = "Hello"
}

Adding a badge to an xpages applayout title bar node item

Is it possible to add a simple badge to a title bar node item? Each tab in my layout represents a separate application. My users would like to see a number next to the name on the tab to indicate whether there are documents in that application needing their attention. If no documents, then no badge, just the application name by itself. If there are documents, then display the application name and a badge for the number. I'm not finding a way to include the span tag in a PageLinkNode or BasicLinkNode.
PageLinkNode (xe:pageTreeNode) label can only be plain text.
You can use the image property though:
<xe:this.titleBarTabs>
<xe:pageTreeNode
page="..."
label="Application A"
image="#{javascript: var nr = 5;
nr > 0 ? ('badge' + Math.min(nr, 10) + '.gif') : ''}">
</xe:pageTreeNode>
Add to Resources/Images ten pictures badge1.gif, badge2.gif, ... badge10.gif with the numbers as pictures. badge10.gif would be a 9+ picture.
As an alternative, you could provide the number of documents as part of the label (e.g. "Your Application Name [23]") and convert it on client side onClientLoad event to HTML label + badge-span.

Typo3 list the content of all child-pages as content of the parent page

As the title says, I need to list the content of all child-pages on the parent-page, after its own content. Or the thing I really need is, one page with content and and a menu which links to the different headers of the content. e.g. athe parent-page with content:
**Parent Head**
parent text
*first subhead*
first subtext
*second subhead*
second subtext
and the menu should look like:
Parent
-first subhead
-second subhead
I thought it would be easier if the parent-page "collects" the content of the child-pages.
The other solution was, that the child-pages would be links to extern URLs, to the specific c-IDs of the different contents of the parent-page. But I think this isn't that easy for the website owner, who doesn't know anything about where he can find the right c-ID in the web-page-source-code.
So how would You make that? Or how can I realize the thing with the child-page-content?
EDIT: Have a solution now. Just have to fix, that the submenu will be displayed without childpages.
Here is the code:
temp.contentnav = CONTENT
temp.contentnav {
table = tt_content
select {
pidInList = 7
orderBy = sorting
where = colPos=0
languageField=sys_language_uid
}
renderObj = TEXT
renderObj {
field = header
wrap= <li>|</li>
typolink.parameter.field=pid
typolink.parameter.dataWrap=|#{field:uid}
typolink.ATagParams = class="linkClass"
if.isTrue.field=header
}
wrap = <ul id="submenuClass"> | </ul>
}
page.10.marks.MENU.2.NO.after.cObject < temp.contentnav
Try something like this
temp.pageIds = HMENU
temp.pageIds.entryLevel = 1
temp.pageIds.1 = TMENU
temp.pageIds.1 {
NO.stdWrap.field = uid
NO.allWrap = |,
NO.doNotLinkIt = 1
}
lib.container = CONTENT
lib.container.table = tt_content
lib.container.select {
pidInList.cObject < temp.pageIds
}
There is a content element "Menu/Sitemap" with has an option to render subpages with content.
If you want to do it via TypoScript, render the menu, and then replace the menu items with content of them.
# Pseudocode on menuitem
# assuming you are using css_styled_content
1.allStdWrap.cObject < styles.content.get
# Set pid for CONTENT object from styles.content.get to the uid of the page
# which gets rendered
1.allStdWrap.cObject.select.pidInList.data = uid
Can't provide you with an working snippets atm.

rootline not working with TYPO3 4.5 menus

I'm having problems with TYPO3. I have been using it for quite a few years, since version 3.8 but this is my first site using version 4.5 and I am having problems with the menus and the rootline.
I believe it is related to how the rootline is created. using the code below for the breadcrumb/path type of menu only the current page is displayed. The menu only displays page X using example and code below when in page X and it should be
home > section 1 > sb a > page X
home
--- section 1
------- sub A
---------- page X
--- section 2
Also when displaying menus the ACT state isn't being properly activated. As I understand every page in the path/rootline should activate the ACT state and it is not happening with code below.
Has any thing changed in this version?
I have used both piece of codes in many sites up to now in version 4.5
codes
temp.breadcrumbs = HMENU
temp.breadcrumbs.special = rootline
#temp.breadcrumbs.includeNotInMenu = 1
#temp.breadcrumbs.special.range= -2 | -1
temp.breadcrumbs.special.range = 0
temp.breadcrumbs.1= TMENU
temp.breadcrumbs.1.noBlur = 1
temp.breadcrumbs.1.NO.allWrap= | > |*||*| |
## with and without line ... special.range ...
.....
....
temp.topmenu.1 {
wrap = <ul>|</ul>
# NO.allWrap = <li>|</li>
expAll = 1
NO.wrapItemAndSub = <li>|</li>
# Enable active state and set properties:
ACT = 1
ACT.wrapItemAndSub = <li class="current-menu-item">|</li>
}
temp.topmenu.2 = TMENU
temp.topmenu.2.noBlur = 1
temp.topmenu.2 {
wrap = <ul class="sub-menu">|</ul>
NO.linkWrap = <li>|</li>
# Enable active state and set properties:
ACT = 1
ACT.linkWrap = <li class="active">|</li>
#ACT.allWrap = <li class="selected">|</li>
#ACT.ATagBeforeWrap = 1
}
thanks
Ivan.
as cascaval wrote it's quite common to declare begin and end levels, anyway 0 value is aceptable too, as written in doc for entryLevel
Default is "0" which gives us a menu of the very first pages on the site.
Probably you put some TypoScript on the page X which has Rootlevel field checked, so it avoids traversing the tree up-side. I examined your sample code on first implementation I had available and it works as expected.
The range is supposed to be defined as [begin-level] | [end-level] so try:
temp.breadcrumbs.special.range = 0|-1
...or...
temp.breadcrumbs.special.range = 1|-1
-1 means current page.
-2 means the page one level up from the current page.
NOTE: You should probably set temp.breadcrumbs.includeNotInMenu = 1 because usually you would like to have all the pages in the breadcrumbs (as the structure that breadcrumbs represent wouldn't otherwise make sense), that is including those that you don't want to appear in other menus.
Had the same problem in Typo3 6.2.14 and finally found a solution.
After clearing "Template on Next Level" rootline worked perfectly.
Reason:
the root template was referenced in root templates "Template on Next
Level".
Solution:
edit root template
switch to tabfolder "Options"
clear field "Template on Next Level"

Referencing text input fields in CKEditor dialogs

I've been playing around with this for a couple of weeks now with no success...
In a CKEditor dialog, text input fields are renamed with a unique number - e.g. id: 'txtUrl' will become something like id='27_textinput'.
How do I reference this?
// I feel it should be something like:
var myfield = CKEDITOR.instances.myElement.document.$.body.getId('txtUrl');
// or maybe:
var myfield = CKEDITOR.dialog.getContentElement('info','txtUrl');
// and then:
myfield.value = 'myvalue';
But these don't work. Please help! Thanks in advance, R
This was the final solution:
var dialog = CKEDITOR.dialog.getCurrent();
dialog.setValueOf('info','txtUrl',"http://google.com");
return false;
within an onchange part of an element I now use
dialog = this.getDialog();
alert(dialog.getContentElement('info', 'grootte').getInputElement().$.id);
and it gives 'cke_117_select' as a result. (It's a selectbox)
alert(dialog.getContentElement('info', 'txtUrl').getInputElement().$.id);
gives 'cke_107_textInput'.
I think this is what you (or other visitors to this page) are looking for.
You have a page containing the CKEditor 3 and a dialog pop up. You open from this dialog, another pop up window, that is a JSP page. In order to set a value to a field in the dialog of CKEditor's parent window, you do the following:
window.opener.CKEDITOR.dialog.getCurrent().getContentElement('dialogTabId', 'dialogTabFieldId').setValue('yourValue');
This applies to CKEditor 3.
Look at the api dialog sample:
// Get a reference to the "Link Info" tab.
var infoTab = dialogDefinition.getContents( 'info' );
// Set the default value for the URL field.
var urlField = infoTab.get( 'url' );
urlField['default'] = 'www.example.com';
get
var ckValue = CKEDITOR.instances['txtUrl'].getData();
and set
CKEDITOR.instances['txtUrl'].setData(ckValue);

Resources