I'm trying to build a browse menu in TYPO3 that should be added to all subpages to navigate trough all submenu pages.
That's what I got:
temp.prevPage = HMENU
temp.prevPage {
special = browse
special{
items = prev
value = 22
prev.fields.title = <img src="fileadmin/dev/pics/prev.gif" title="next page" alt="prev page"/>
}
1 = TMENU
1.NO = 1
1.NO.allWrap = |
}
temp.nextPage = HMENU
temp.nextPage {
special = browse
special{
items = next
value = 22
next.fields.title = <img src="fileadmin/dev/pics/next.gif" title="next page" alt="prev page" />
}
1 = TMENU
1.NO = 1
1.NO.allWrap = |
}
To the Problem: The next and prev arrows are shown on any pid value correctly but it doesn't work if it is the pid of the actual page (actually I could leave value away, then it should work on the actual page but it doesn't).
Example: I'm currently on page with id (pid) 23, there the links to pid 21 (prev) and to 23 (next) are shown. But if I go to page with id 22, the links to prev an next disapear.
Template is on _root.
Menu-Tree:
_root
- Home
- pid19
- - pid20
- - pid21
- - pid22
- - pid23
- pid24
- - pid25
...
Any help will be highly appreciated.
You need to remove the special.value to always take the current pid. It could look something like this (slightly different, but copied from a live project):
lib.navi.horizontal = COA
lib.navi.horizontal {
10 = HMENU
10 {
special = browse
special {
items = prev
}
1 = TMENU
1.noBlur = 1
1.NO {
ATagParams = class="nav-arrow nav-prev"
ATagTitle.dataWrap = {field:title}
}
}
20 = HMENU
20 {
special = browse
special {
items = next
}
1 = TMENU
1.noBlur = 1
1.NO {
ATagParams = class="nav-arrow nav-next"
ATagTitle.dataWrap = {field:title}
}
}
}
This code has to go on pid 19 in your page structure
Related
I'm currently working on modifying a Tree View control (Telerik MVC Extensions) for a customer request. Their request is a simple one: if an item within the tree has an Attachment, add a paperclip beside the node to identify it.
I have so far been able to do so but, found a small hiccup with this. I can add the image to certain nodes that have an Attachment, however, all nodes that don't should have no image (by that, I mean they should appear normal within the tree). Instead though, I find that the tree places a blank the size of the paperclip image.
Is there a way to dynamically turn off this blank (aka not add an Image Url if unnecessary)? Below is my code where I'm executing this process (is done on the expansion method of the tree due that only the bottom level shows the Attachments).
Navigation Controller
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GetNextTreeViewLevel(TreeViewItem node)
{
...
//If bottom layer, then execute the following
var data = _TreeRepo.GetProcessesByParcel(int.Parse(values[1]), cntTreeList);
nodes = from item in data
select new TreeViewItem
{
Text = item.strProcess,
Value = "PR" + "," + item.cntProcess.ToString(),
LoadOnDemand = false,
Enabled = true,
Selected = SelectedSearchResult.ToString().Length > 0
&& SelectedSearchResult.ToString().Split('~').Length > 3
&& decimal.Parse(SelectedSearchResult.ToString()
.Split('~')
.Last()
.Substring(2)) == item.cntProcess
ImageUrl = item.ysnHasAttachment.HasValue && item.ysnHasAttachment.Value == 1
? #"/Content/NewImages/attachment.png"
: string.Empty
};
return new JsonResult { Data = nodes };
}
Screen shots of what it looks like without/with code for Image Url:
I at long last came up with a solution to this issue. The problem was how I was getting my data added to the nodes. The original logic was doing a Linq query after fetching the data to get an IEnumerable object.
Because of that, every node was trying to add an image (even if there was none). Hence the weird looking space. Below is how I reworked this logic to correctly get my data.
var processNodes = new List<TreeViewItem>();
var data = _TreeRepo.GetProcessesByParcel(int.Parse(values[1]), cntTreeList);
foreach (var item in data)
{
#region Process has at least one Attachment
if (item.ysnHasAttachment.HasValue && item.ysnHasAttachment.Value == 1)
processNodes.Add(new TreeViewItem
{
Text = item.strProcess,
Value = "PR" + "," + item.cntProcess.ToString(),
LoadOnDemand = false,
Enabled = true,
Selected = SelectedSearchResult.ToString().Length > 0
&& SelectedSearchResult.ToString().Split('~').Length > 3
&& decimal.Parse(SelectedSearchResult.ToString()
.Split('~')
.Last()
.Substring(2)) == item.cntProcess,
ImageUrl = "/Content/NewImages/smallAttachment.png"
});
#endregion
#region Process has no Attachments
else
processNodes.Add(new TreeViewItem
{
Text = item.strProcess,
Value = "PR" + "," + item.cntProcess.ToString(),
LoadOnDemand = false,
Enabled = true,
Selected = SelectedSearchResult.ToString().Length > 0
&& SelectedSearchResult.ToString().Split('~').Length > 3
&& decimal.Parse(SelectedSearchResult.ToString()
.Split('~')
.Last()
.Substring(2)) == item.cntProcess
}
#endregion
}
nodes = processNodes;
At this point, you can now return the nodes. Those that should have had an Attachment icon will, and those that shouldn't won't. Funny how 4 months later, you can come up with something off the cuff.
I have a Tableviewcontroller BeamsNameVC with 2 variables: Name and number.
If for example, the number is 7, and if I click on any row in this View controller, it will segue to another TableViewcontroller SpansListVC and than it will show 7 rows: S1, S2, S3, S4, S5, S6 & S7.
I want to save these Data, so I created 2 swift files:
class StructureElement: NSObject, NSCoding {
var name = ""
var nbrSpans = ""
var spans = [LoadDetailsForEachSpan]()
and
class LoadDetailsForEachSpan: NSObject, NSCoding {
var i_SpanName = ""
var i_Spanlength = ""
var i_ConcentratedLoadForEachSpans = [ConcentratedLoadForEachSpan]()
I created a protocol with the following:
let spanNbr = Int(structureElement[newRowIndex].nbrSpans)
let newElementDetailSpan = LoadDetailsForEachSpan()
for i in 0...spanNbr! {
newElementDetailSpan.i_SpanName = "S" + " \(i)"
structureElement[newRowIndex].spans.append(newElementDetailSpan)
}
If i run the application, it will segue to * SpansListVC* but all values are the last i.
Example:
if name is Test 7 and number of span is 7, I will be having inside *[Spans] * 7 values with the same name:
spans[0] = S 7
spans[1] = S 7
....
Any mistake with above code?
Welcome to the hell that mutable data objects can be ;). You are creating a single LoadDetailsForEachSpan instance and add that same instance a number of times to the array, while setting the i_SpanName property of that same instance every time the loop is iterated. You probably want to pull the instance creation into the loop:
for i in 0...spanNbr! {
let newElementDetailSpan = LoadDetailsForEachSpan()
newElementDetailSpan.i_SpanName = "S" + " \(i)"
structureElement[newRowIndex].spans.append(newElementDetailSpan)
}
Thanks #thm for your reply.
however, i find another solution as follow and it works:
var spanDetailAndLoadItem: [SpanDetailsAndLoads] = []
for var i in 1...nbr! {
let item = SpanDetailsAndLoads(name: "S\(i) - S\(i + 1)")
spanDetailAndLoadItem.append(item)
}
self.spans = spanDetailAndLoadItem
with the following snippet I get an ID counting up for every following menu item, this is the html output:
<a href="http://example.com/index.php?id=17" id="item-1"> <!-- item-2 etc -->
but I'd need this counting up with the following output:
<a href="http://example.com/index.php?id=17&item=1"> <!-- item=2 etc -->
the snippet:
1 = TMENU
1 {
expAll = 1
NO = 1
NO {
before.cObject = LOAD_REGISTER
before.cObject{
fontawesome.cObject=TEXT
fontawesome.cObject.required = 1
fontawesome.cObject.data.dataWrap = DB:pages:{field:uid}:tt_content_fontawesome_icon
fontawesome.cObject.noTrimWrap = | <i class="fa |"></i> |
}
ATagBeforeWrap = 1
linkWrap = {register:fontawesome}|
ATagParams = id="item-{register:count_MENUOBJ}"
allStdWrap.insertData = 1
wrapItemAndSub = <li>|</li>
stdWrap.htmlSpecialChars = 1
}
}
I tried with typolink {} and additionalParams but that makes {register:count_MENUOBJ} unavailable for a reason I cannot grasp, probabely some conflict within data types ...
also the linkwrap with {register:fontawesome} is delicate ...
Inside of NO {} try these two lines without allStdWrap.insertData:
additionalParams.data = register:count_MENUOBJ
additionalParams.wrap = &item=|
If it would not work, try another value to check if it basically would work:
additionalParams.data = field:uid
additionalParams.wrap = &item=|
Have a look at the documentation: https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html
I'm generating a list of the 10 latest created pages. My general page-sorting in the Backend is:
root
-- category1
---- article1
---- article2
---- article3
-- category2
---- article4
---- article5
---- article6
So the list has to contain the title of the article plus the title of its parent page, the category. I got most of it running but I struggle to output the category-title.
Here's my TS:
lib.lastUpdated = COA
lib.lastUpdated {
10 = HMENU
10.wrap = <div class="lastupdated">|</div>
10 {
special = updated
special.value = 5
special.depth = 4
special.beginAtLevel = 2
special.mode = starttime
maxItems = 10
alternativeSortingField = starttime desc
1 = TMENU
1 {
NO {
allWrap = <div class="lu-elem">|</div>
after.cObject = COA
after.cObject {
10 = TEXT
10 {
field = starttime
date = d.m.y
noTrimWrap = | <span class="created">|</span><br />|
}
20 = TEXT
20 {
field = subtitle
wrap = <p class="subtitle">| <p>
}
30 = RECORDS #this is not working
30 {
source.field = uid
tables = pages
conf.pages = TEXT
conf.pages.data = leveltitle:0 #displays title of CURRENT page's parent
}
}
}
}
}
}
Anybody can help?
To get the title of the parent page:
30 = RECORDS
30 {
source.field = uid
tables = pages
conf.pages = RECORD
conf.pages {
# select the uid of the parent page of the current page
source.field = pid
tables = pages
dontCheckPid = 1
# print the header
conf.pages = TEXT
conf.pages.field = header
}
}
I want to make a menu containing both public and access restricted pages, based on the following requirements:
public pages should be linked, regardless whether the user is logged in or not
access restricted pages should not be linked if the user is not logged in
access restricted pages should be linked if the user is logged in
This is what I have so far:
lib.menu = HMENU
lib.menu.1 = TMENU
lib.menu.1 {
// Satisfies requirement 2
NO.doNotLinkIt = 1
// Satisfies requirement 3
USR = 1
}
However, as you would expect, requirement 1 isn't satisfied this way. I can't come up with a way to make lib.menu.1.NO conditional based on the page being public or access restricted.
If you set NO.doNotLinkIt = 1 then all normal pages are not linked. Actually you want to set showAccessRestrictedPages = <uid> where the uid is the ID if your page with the login form. See documentation. You can set CUR.doNotLinkIt = 1, for requirement 2.
Try this it will also make access restricted page visible irrespective of login status
menu.right.3 = TMENU
menu.right.3.wrap = <ul>|</li></ul></li>
menu.right.3 {
expAll = 0
NO.ATagTitle.field = title
NO.allWrap = <li>|</li>
ACT = 1
ACT.ATagTitle.field = title
ACT.allWrap = <li class="active">|
showAccessRestrictedPages = <login page uid>
showAccessRestrictedPages.addParams =
&return_url=###RETURN_URL###&pageId=###PAGE_ID###
}