My aim is to create a menu in TYPO3 6, which can have multiple rows. Assuming I have 10 items that need to be listed in the menu, then 5 should be in the first row and <br/> after that and then the other five.
But if there are only 6, then 3 on first row then <br> and the next 3 on the next row.
But if there are only 2 or any number less than 4, then they should all be listed in one row
For 10 items
Item-1 Item-2 Item-3 Item-4 Item-5
Item-6 Item-7 Item-8 Item-9 Item-10
For 6 items
Item-1 Item-2 Item-3
Item-4 Item-5 Item-6
For <4 items
Item-1 Item-2 Item-3
but for 5 items
Item-1 Item-2 Item-3 Item-4
Item-5
So far, I have this:
lib.level1Menu = COA
lib.level1Menu {
10 = HMENU
10.1 = TMENU
10.1 {
wrap = <center><ul><br/>|</ul></center>
NO {
stdWrap.cObject = COA
stdWrap.cObject {
10 = TEXT
10.field = title
if.value.data = register:count_HMENU_MENUOBJ
if.negate = 1
if.isLessThan.prioriCalc=1
if.isLessThan.cObject=TEXT
if.isLessThan.cObject.insertData=1
if.isLessThan.cObject.value = ({register:count_menuItems}+1)/2
wrap = <li><br/>|</li>
}
}
}
20 < .10
20.1.wrap = <center><ul><br/>|</ul></center>
20.1.NO.stdWrap.cObject.if.negate >
}
Which does not work properly.
Related
Given a section of html source code named li as follows:
[<li>Project construction cycle</li>,
<li>
Start date: 2019...
Completion date: 2021... <a class="login-btn" href="javascript:">Click to view details</a>
</li>,
<li>Preliminary preparation progress</li>,
<li>
The project has been completed by... <a class="login-btn" href="javascript:">Click to view details</a>
</li>,
<li>Progress in design work</li>,
<li>
The project design has... <a class="login-btn" href="javascript:">Click to view details</a>
</li>,
<li>Procurement of equipment</li>,
<li>
The project equipment... <a class="login-btn" href="javascript:">Click to view details</a>
</li>,
<li>Project construction progress</li>,
<li>
The project is in... <a class="login-btn" href="javascript:">Click to view details</a>
</li>]
How could we extract Start date and Completion date and convert them to a dataframe?
PS: I convert it to dataframe because I need to concatenate it with other columns.
The expected result:
Start date Completion date
0 2019 2021
Thanks.
Updates:
li = str(li)
s = re.compile('Start date:[0-9]{4}').findall(li)
df1 = pd.DataFrame([x.split(':')for x in s ]).set_index(0).T
e = re.compile('Completion date:[0-9]{4}').findall(li)
df2 = pd.DataFrame([x.split(':')for x in e ]).set_index(0).T
# df = pd.concat([df1, df2], axis = 1)
New update:
rmktxt2 = soup.find("table", attrs={"id":"mse_new"}).find("ul", attrs={"class":"rmktxt2"})
li = rmktxt2.find_all("li")
li = str(li)
li = " ".join(li.split())
regex = r"(Start date:\d{4}|Completion date:\d{4})"
data = re.findall(regex, li)
df = pd.DataFrame([x.split(':')for x in data]).set_index(0).T
print(df)
Out:
0 Start date Completion date
1 2019 2021
Now how can I set index 0 starting from row of 2019 2021?
Updates:
regex = r"Start date:(\d{4}).*Completion date:(\d{4})"
data = re.findall(regex, li)[0]
out['Start date'] = data[0]
out['Completion date'] = data[1]
df = pd.DataFrame([out])
Out:
Start date Completion date
0 2019 2021
You may try:
(Start date: \d{4}|Completion date: \d{4})
Explanation of the above regex:
(Start date: \d{4}) - Represents first capturing group matching Start date: literally along with digits appearing exactly 4 times.
| - Represents alternation.
Completion date: \d{4}) - Matches Completion date: literally along with digits appearing exactly 4 times.
You can find the demo of the above regex in here.
Code Demo
I am trying to loop through the options or items of a drop down menu, but I don't know the number of items as it will be changeable every time.
Here's the html part of the sList3
<select name="ctl00$ContentPlaceHolder1$Dschool" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$Dschool\',\'\')', 0)" id="ContentPlaceHolder1_Dschool" style="font-size:12pt;font-weight:bold;width:500px;">
<option selected="selected" value="0"> Select From Menu </option>
<option value="311223">first option</option>
<option value="311625">some option</option>
</select>
Here's my code that I have started
For i = 1 To 4
Set sList1 = .FindElementById("ContentPlaceHolder1_Dedara").AsSelect
sList1.SelectByIndex i
.Wait 2000
Set sList2 = .FindElementById("ContentPlaceHolder1_Drel").AsSelect
sList2.SelectByIndex 1
.Wait 2000
Set sList3 = .FindElementById("ContentPlaceHolder1_Dschool").AsSelect
'How can I loop through the options (unknown in length)
Next i
I would like to loop each option and debug.print the value of the option.
SOLUTION
With the help of JeffC this is the final solution
For j = 1 To sList3.Options.Count
Debug.Print sList3.Options(j).Text
Next j
I think you can use for each loop
WebElement selectElement = driver.findElement(By.xpath("//select[#id='ContentPlaceHolder1_Dschool']"));
Select select = new Select(selectElement);
List<WebElement> options = select.getOptions();
for (WebElement we : options)
{
System.out.println("Element="+we.getText());
}
You can use CSS selector to get collection of the options under the parent id
Dim elements As Object, element As Object
Set elements = driver.FindElementsByCss("#ContentPlaceHolder1_Dschool option")
Then loop
For Each element In elements:
Debug.Print element.text
Next
CSS:
If the id is dynamic switch css to
[id^=ContentPlaceHolder1] option
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'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