multiple navigation menus with liferay theme-settings - liferay

I am creating a theme with multiple navigation menus for a theme using theme-settings, in liferay look-and-feel.xml I have added the below code:
<settings>
<setting configurable="true" key="navigation" type="select"
options="left-vertical,right-vertical,horizontal" value="horizontal" />
</settings>
portal_normal.vm file:
<!DOCTYPE html>
#parse ($init)
<html class="$root_css_class" dir="#language ("lang.dir")" lang="$w3c_language_id">
<head>
<title>$the_title - $company_name</title>
<meta content="initial-scale=1.0, width=device-width" name="viewport" />
$theme.include($top_head_include)
</head>
## navigation menu selection related code
#set ($navigationLeft = $theme.getSetting("navigation"))
#if ($navigationLeft == "left")
#set ($css_class = "${css_class} navigation-left")
#end
#if ($navigationLeft == "left-right")
#set ($pull1 = "")
#set ($pull2 = "pull-right")
#else
#set ($pull1 = "pull-right")
#set ($pull2 = "")
#end
<body class="$css_class">
#language ("skip-to-content")
$theme.include($body_top_include)
#dockbar()
## docbar settings
#set ($dockbar = $theme.getSetting("dockbar-mode"))
#if ($dockbar == "split")
#set ($css_class = "${css_class} dockbar-split")
#end
#set ($navigationLeft = $theme.getSetting("logo-menu-direction"))
#if ($navigationLeft == "left-right")
#set ($pull1 = "")
#set ($pull2 = "pull-right")
#else
#set ($pull1 = "pull-right")
#set ($pull2 = "")
#end
<div class="container-fluid" id="wrapper">
<header id="banner" role="banner">
<div id="heading">
<h1 class="site-title">
<a class="$logo_css_class" href="$site_default_url" title="#language_format ("go-to-x", [$site_name])">
<img alt="$logo_description" height="$site_logo_height" src="$site_logo" width="$site_logo_width" />
#* #if ($show_site_name)
<span class="site-name" title="#language_format ("go-to-x", [$site_name])">
$site_name
</span>
#end
*#
</a>
</h1>
<div class="navigation-menu $pull2">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
</div>
<h2 class="page-title">
<span>$the_title</span>
</h2>
</div>
#if ($has_navigation || $is_signed_in)
#parse ("$full_templates_path/navigation.vm")
#end
</header>
<div id="content">
<nav id="breadcrumbs">#breadcrumbs()</nav>
#if ($selectable)
$theme.include($content_include)
#else
$portletDisplay.recycle()
$portletDisplay.setTitle($the_title)
$theme.wrapPortlet("portlet.vm", $content_include)
#end
</div>
<footer id="footer" role="contentinfo">
<p class="powered-by">
#language ("powered-by") Liferay
</p>
</footer>
</div>
$theme.include($body_bottom_include)
$theme.include($bottom_include)
</body>
</html>
By default I am showing horizontal menu.
Now when the user selects left-vertical, or right-vertical I am displaying the navigation menu correctly but whenever user selects the horizontal I need to show the default horizontal navigation menu. How do I achieve this?
In the above code I have not written any code regarding 'horizontal' because again I need to write CSS for it. Instead of when I apply theme for first time it will show horizontal menu that settings I need to apply when I select horizontal.
How do I achieve it?

Using the GetterUtil you can have a default value in case of the select has no value yet selected.
This is an example:
#set ($navigation = $getterUtil.getString($theme.getSetting("navigation"),"horizontal"))

Related

Need help removing active status on navigation menu

I just need the focus to stay once the element is clicked. I can't get it to work. This code below is from my masterpage. The hover works ok, but after clicking one of the menu options, it does not stay focused and goes right back to the home button. Can someone possibly shed some light on why this isn't working?
<body>
<script type="text/javascript" src="wz_tooltip.js"></script>
<form id="form1" runat="server">
<br />
<br />
<center>
<!-- start header -->
<header>
<div class="container">
<div class="navbar navbar-static-top">
<div class="navigation">
<nav>
<ul class="nav topnav bold" >
<li class="dropdown active">
<a id="nav1" href="../default.aspx" runat="server">HOME </a>
</li>
<li class="dropdown">
<a id="nav2" href="../reverse_mortgages.aspx" runat="server" onclick="setNavagation();">REVERSE MORTGAGE FAQ</a>
</li>
<li class="dropdown">
<a id="nav3" href="../loan_process.aspx" runat="server">OUR PROCESS</a>
</li>
<li id="nav4" class="dropdown">
GET QUOTE
</li>
<li id="nav5" class="dropdown">
ABOUT
</li>
<li id="nav6" class="dropdown">
CONTACT
</li>
</ul>
</nav>
</div>
<!-- end navigation -->
</div>
</div>
</header>
</center>
<script type="text/javascript">
function setNavigation() {
var path = window.location.pathname;
path = path.replace(/\/$/, "");
path = decodeURIComponent(path);
if (path.substring(1, path.length) === "") { // this was the home page loading already active
return;
}
$("li.active").removeClass("active"); // remove class 'active' all list items
$(".navigation a").each(function () {
var href = $(this).attr('href');
if (path.substring(1, path.length) === href) {
$(this).parent('li').addClass('active');
return;
}
});
}
</script>
<!-- end header -->

Crawling a given URL w/ BeautifulSoup (Python3)

Halp!
I'm trying to write a web-crawler in python. The goal is to (eventually) loop through a list of domains, crawl all local-URLs within those domains, and dump all of the HTML content back to my host.
For now, I'm handing the script a single domain (http://www.scrapethissite.com). I've defined a queue, as well as sets for new/processed/local/foreign/broken-URLs. Based on the output, it looks like the script is reading in HTML of the page, grabbing the first local_URL ('https://scrapethissite.com/lessons/'), but failing to process that URL by adding it to the queue.
Ideally, the script would spit out each input URL's output into its own directory, preserving the DOM of the TLD. But I'd be happy just to get the queue working.
Here's my code:
from bs4 import BeautifulSoup
import requests
import requests.exceptions
from collections import deque
from urllib.parse import urlsplit, urlparse
from urllib.request import Request, urlopen
import requests
from html.parser import HTMLParser
import lxml
#set targets
url = 'https://scrapethissite.com'
new_urls = deque(([url]))
processed_urls = set()
local_urls = set()
foreign_urls = set()
broken_urls = set()
#process urls until we exhaust queue
while len(new_urls):
url = new_urls.popleft()
processed_urls.add(url)
print("processing %s..." % url)
try:
response = requests.get(url).text
print(response)
print(new_urls)
except(requests.exceptions.MissingSchema, requests.exceptions.ConnectionError, requests.exceptions.InvalidURL, requests.exceptions.InvalidSchema):
broken_urls.add(url)
print(("this %s failed") % url)
continue
##get base URL to differentiate local and foreign addresses
###not working
print("differentiating addresses...")
parts = urlsplit(url)
base = "{0.netloc}".format(parts)
strip_base = base.replace("www.","")
base_url = "{0.scheme}://{0.netloc}".format(parts)
path = url[:url.rfind('/')+1] if '/' in parts.path else url
#initialize soup
print("initializing soup...")
response = requests.get(url).text
soup = BeautifulSoup(response, 'lxml')
#get links in HTML
for link in soup.find_all('a'):
anchor = link.attrs["href"] if "href" in link.attrs else ''
#scrape page for links
print("scraping links...")
if anchor.startswith('/'):
local_link = base_url + anchor
local_urls.add(local_link)
elif strip_base in anchor:
local_urls.add(anchor)
elif not anchor.startswith('http'):
local_link = path + anchor
local_urls.add(local_link)
else:
foreign_urls.add(anchor)
print(forieng_urls)
print(local_urls)
#to crawl local urls
#...and add them to sets
for i in local_urls:
if not i in new_urls and not i in processed_urls:
new_urls.append(i)
#to crawl all URLs
#for i in local_urls:
#if not link in new_urls and not link in processed_urls:
#new_urls.append(link)
print("new urls: %s" % new_urls)
print("processed urls: %s" % processed_urls)
print("broken urls: %s" % broken_urls)
And here's the output:
(base) $ crawler % python3 bsoup_crawl.py
processing https://scrapethissite.com...
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Scrape This Site | A public sandbox for learning web scraping</title>
<link rel="icon" type="image/png" href="/static/images/scraper-icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A public sandbox for learning web scraping">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-MfvZlkHCEqatNoGiOXveE8FIwMzZg4W85qfrfIFBfYc= sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<link href='https://fonts.googleapis.com/css?family=Lato:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="/static/css/styles.css">
</head>
<body>
<nav id="site-nav">
<div class="container">
<div class="col-md-12">
<ul class="nav nav-tabs">
<li id="nav-homepage">
<a href="/" class="nav-link hidden-sm hidden-xs">
<img src="/static/images/scraper-icon.png" id="nav-logo">
Scrape This Site
</a>
</li>
<li id="nav-sandbox">
<a href="/pages/" class="nav-link">
<i class="glyphicon glyphicon-console hidden-sm hidden-xs"></i>
Sandbox
</a>
</li>
<li id="nav-lessons">
<a href="/lessons/" class="nav-link">
<i class="glyphicon glyphicon-education hidden-sm hidden-xs"></i>
Lessons
</a>
</li>
<li id="nav-faq">
<a href="/faq/" class="nav-link">
<i class="glyphicon glyphicon-flag hidden-sm hidden-xs"></i>
FAQ
</a>
</li>
<li id="nav-login" class="pull-right">
<a href="/login/" class="nav-link">
Login
</a>
</li>
</ul>
</div>
</div>
</nav>
<script type="text/javascript">
var path = document.location.pathname;
var tab = undefined;
if (path === "/"){
tab = document.querySelector("#nav-homepage");
} else if (path.indexOf("/faq/") === 0){
tab = document.querySelector("#nav-faq");
} else if (path.indexOf("/lessons/") === 0){
tab = document.querySelector("#nav-lessons");
} else if (path.indexOf("/pages/") === 0) {
tab = document.querySelector("#nav-sandbox");
} else if (path.indexOf("/login/") === 0) {
tab = document.querySelector("#nav-login");
}
tab.classList.add("active")
</script>
<div id="homepage">
<section id="hero">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<img src="/static/images/scraper-icon.png" id="townhall-logo" />
<h1>
Scrape This Site
</h1>
<p class="lead">
The internet's best resource for learning <strong>web scraping</strong>.
</p>
<br><br><br>
<a href="/pages/" class="btn btn-lg btn-default" />Explore Sandbox</a>
<a href="/lessons/" class="btn btn-lg btn-primary" />
<i class="glyphicon glyphicon-education"></i>
Begin Lessons →
</a>
</div><!--.col-->
</div><!--.row-->
</div><!--.container-->
</section>
</div>
<section id="footer">
<div class="container">
<div class="row">
<div class="col-md-12 text-center text-muted">
Lessons and Videos © Hartley Brody 2018
</div><!--.col-->
</div><!--.row-->
</div><!--.container-->
</section>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha256-Sk3nkD6mLTMOF0EOpNtsIry+s1CsaqQC1rVLTAy+0yc= sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pnotify/2.1.0/pnotify.core.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/pnotify/2.1.0/pnotify.core.min.css" rel="stylesheet" type="text/css">
<!-- pnotify messages -->
<script type="text/javascript">
PNotify.prototype.options.styling = "bootstrap3";
$(function(){
});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
<!-- golbal video controls -->
<script type="text/javascript">
$("video").hover(function() {
$(this).prop("controls", true);
}, function() {
$(this).prop("controls", false);
});
$("video").click(function() {
if( this.paused){
this.play();
}
else {
this.pause();
}
});
</script>
<!-- insert google analytics here -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-41551755-8', 'auto');
ga('send', 'pageview');
</script>
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '764287443701341');
fbq('track', "PageView");</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=764287443701341&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
<!-- Google Code for Remarketing Tag -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 950945448;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/950945448/?guid=ON&script=0"/>
</div>
</noscript>
<!-- Global site tag (gtag.js) - Google AdWords: 950945448 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-950945448"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-950945448');
</script>
</html>
deque([])
differentiating addresses...
initializing soup...
scraping links...
new urls: deque(['https://scrapethissite.com/lessons/', <a class="btn btn-lg btn-primary" href="/lessons/"></a>])
processed urls: {'https://scrapethissite.com'}
broken urls: set()

Escape script to hide/reveal textarea

I need to make my button click to reveal the textarea so the user can choose between uploading either an image or a text message. I can see the hidden/visible element kicking in when I run the page but it doesn't remain in the new state. It immediately reverts back to whatever it was originally set as.
I'm guessing that I'm not escaping the script properly. Any thoughts?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Site Media</title>
</head>
<header id="headtitle">
</header>
<body>
<div id="PostContainer"><br>
<textarea id="textmessage" rows="7" cols="40" maxlength="280" placeholder="Enter message here..." width="100%" style="visibility: hidden"></textarea><br>
<form class="UploadButtonContainer">
<button id="textbutton" type="submit" name="submit" onclick="revealinput()" style="display: none;"></button>
<label for="textbutton" style="cursor: pointer;" ><img src="Images/AYE PING.png" width="30%" alt="Choose Text Post" >
</label>
</form>
<script>
function revealinput() {
var x = document.getElementById("textmessage");
if (x.style.visibility === "hidden") {
x.style.visibility = "visible";
} else {
x.style.visibility = "hidden";
}
}
</script>
</div>
</body>
</html>
The script didn't like the button being inside a tag. I changed it to a tag and it works now.

Using VBA to click a javascript link, get "object required" error

I am attempting to access a website on IE using VBA to pull a report of the previous weeks transactions. I was able to login and navigate to the report page. However, when I try to click a link for an advanced search I get the error "Object Required"
Below is the HTML I have isolated as belonging to the link:
<!-- Form Actions -->
<input type="button" id="searchtTxn" value="Search"
class="align-right margin-top"
style="float: right; font-size: 11px; margin-top: 5px;">
**<div id="secondary-button"
style="border: none; background: none; height: 26px; font-size: 11px; float: right;">
<a href="javascript:void(0);" id="moreOptions" class="mouseover"><strong>More
Options</strong>**
</a>
</div>
Specifically, I am trying to select the "moreOptions" item. I have also tried selecting based on the "mouseover" class with no luck. I also tried to create a saved report that I could just click based on the class and ID, the HTML for this search is below:
<div class="div-scroll portletContentJS"
style="height:145px !important;" id="savedSearchPortlet"
style="overflow-y: auto;">
<div class="savedsearch-record">
<table style="width:100%;" class='draggable' >
<tr>
<td class="wrap-savedsearch-report">
<div class="constrained">
<a href="javascript:void(0);" class="searchtResultTxn hasTooltip"
id="164035" style="text-decoration: underline;font-size:11px; padding-left: 2px;">Prev Week ACH </a>
<div class="hidden">
<!-- This class should hide the element, change it if needed -->
<table>
<tr>
<td style='word-wrap:break-word;word-break:break-all;max-width:150px;min-width:50px;'>Prev Week ACH</td>
</tr>
</table>
</div>
I am using the below VBA to access the website and navigate to the page I need. The code errors out when I try to pull the Element "moreOptions". I built in a 20 second wait time on the page that doesn't work in case the link wasn't available yet to no avail. I have gone as high as 1 minute with no results.
Sub login1()
Dim IE As Object
Dim HTMLDoc As Object
Dim objCollection As Object
Dim allHREFs As New Collection
Const navOpenInNewTab = &H800
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "https://www.treasury.pncbank.com/idp/esec/login.ht"
Do While IE.Busy Or IE.readyState <> 4: Loop
Set HTMLDoc = IE.Document
With HTMLDoc
HTMLDoc.getElementById("txtUserID").value = "XXXX"
HTMLDoc.getElementById("txtOperID").value = "XXXXXX"
HTMLDoc.getElementById("txtPwd").value = "XXXXXX"
End With
Set objCollection = IE.Document.getElementById("loginFormButton")
objCollection.Click
Do While IE.Busy Or IE.readyState <> 4: Loop
Application.Wait (Now + TimeValue("0:00:10"))
Set objCollection = IE.Document.getElementById("IR")
objCollection.Click
Application.Wait (Now + TimeValue("0:01:00"))
Set objCollection = IE.Document.getElementById("moreOptions")
objCollection.Click
Do While IE.Busy Or IE.readyState <> 4: Loop
End Sub
Any help here would be greatly appreciated. Please let me know if you need additional details. As it is a banking website I will not be able to provide login credentials but let me know if you need more of the HTML code.
EDIT to Add Full Page HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PINACLE - PNC</title>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE;"/>
<style>
#import "/portal/shared/style/new-navigation/stylesheet.css";
#import "/portal/shared/style/new-navigation/navbar.css";
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/portal/shared/js/jQuery/jQuery.min.js"></script>
<script type="text/javascript" src="/portal/shared/js/jQuery/jquery-migrate.min.js"></script>
<!-- TeaLeaf config file needs to come before SDK -->
<script type="text/javascript" src="/portal/service/js/TealeafSDKConfig.js"></script>
<script type="text/javascript" src="/portal/service/js/TealeafSDK.js"></script>
<script type="text/javascript" src="/portal/shared/js/dojotoolkit/dojo/dojo.js"
djConfig="parseOnLoad:true"></script>
<script type="text/javascript" src="/portal/shared/js/dojotoolkit/dojo/portal.js"></script>
<script type="text/javascript" src="/portal/shared/js/common/navigation.js"></script>
<!-- Carousel - Navigation -->
<script type="text/javascript" src="/portal/shared/js/newPrimaryNav/navbar.js"></script>
<script type="text/javascript" src="/portal/shared/js/newPrimaryNav/jquery.tinycarousel2.js"></script>
<!-- End Carousel - Navigation -->
<!-- Draggable -->
<script type="text/javascript" src="/portal/shared/js/newPrimaryNav/jquery-ui.min.js"></script>
<script type="text/javascript" src="/portal/shared/js/newPrimaryNav/draggable.js"></script>
<link rel="stylesheet" href="/portal/shared/style/jquery-ui.css">
<!-- End Draggable -->
<script type='text/javascript' src='/portal/shared/js/engine.js'></script>
<script type='text/javascript' src='/portal/shared/js/util.js'></script>
<script type='text/javascript' src='/portal/dwr/interface/PortletDisplayHelper.js'></script>
<script type='text/javascript' src='/portal/dwr/interface/AjaxSessionManager.js'></script>
<SCRIPT LANGUAGE="JScript" TYPE="text/javascript">
</SCRIPT>
<script type="text/javascript">
(function() {
var host = '/tmmps/payee.js';
var sn = document.createElement('script');
sn.setAttribute('async', true);
sn.setAttribute('type', 'text/javascript');
sn.setAttribute('src', host);
var s = document.getElementsByTagName('head')[0];
s.appendChild(sn);
})();
</script>
<!-- Add meta tag to enable PINACLE Smart App Banner on mobile devices -->
<script type="text/javascript">
if ( /(iPad).*AppleWebKit.*Mobile.*Safari/.test(navigator.userAgent) ) {
var headNode = document.getElementsByTagName("head")[0];
var sbNode = document.createElement('meta');
sbNode.name = 'apple-itunes-app';
sbNode.content = 'app-id=804888748';
headNode.appendChild(sbNode);
} else if ( /(iPhone|iPod).*AppleWebKit.*Mobile.*Safari/.test(navigator.userAgent) ) {
var headNode = document.getElementsByTagName("head")[0];
var sbNode = document.createElement('meta');
sbNode.name = 'apple-itunes-app';
sbNode.content = 'app-id=874929964';
headNode.appendChild(sbNode);
}
</script>
<!-- Set the required variables for Web Analytics -->
<script type="text/javascript">
var page_data = {
"site_name" : "pin",
"language" : "en",
"brandname" : "PINACLE",
"page_name" : "dashboard",
"page_type" : "",
"user_type" : "",
"page_error" : [],
"events" : []
};
<!-- Set the required theme values for EN Alerts -->
var delay = setSecond(5);
var mcSrc = '/portal/isc/ITS?svcnum=410&lte=999&relayState=newMessage&sky=xGTwyoiPngrh1eNFu3twqg%3d%3d';
</script>
<script id="pendo-snippet">
var pendoFlag = 'Y';
var pendoKey = '67a13df9-2e80-4942-4c32-6c799c2b8a67';
var pendoUrl = 'https://cdn.pendo.io/agent/static/';
var account = '10bf187d:013aea5bee72:50e1:01161136';
var visitor = '08757603:016a2273446c:442c:7922f8fb';
if(pendoFlag != null && pendoFlag == 'Y' ){
(function(apiKey){
(function(p,e,n,d,o){var v,w,x,y,z;o=p[d]=p[d]||{};o._q=[];
v=['initialize','identify','updateOptions','pageLoad'];for(w=0,x=v.length;w<x;++w)(function(m){
o[m]=o[m]||function(){o._q[m===v[0]?'unshift':'push']([m].concat([].slice.call(arguments,0)));};})(v[w]);
y=e.createElement(n);y.async=!0;y.src=pendoUrl+apiKey+'/pendo.js';
z=e.getElementsByTagName(n)[0];z.parentNode.insertBefore(y,z);})(window,document,'script','pendo');
// Call this whenever information about your visitors becomes available
// Please use Strings, Numbers, or Bools for value types.
pendo.initialize({
visitor: {
id: visitor
},
account: {
id: account
}
});
})(pendoKey);
}
</script>
<!-- DTM tag for Web Analytics -->
<script type="text/javascript" src="//assets.adobedtm.com/1d90950c926aacaf003e1e8e48aeb1189d4d7901/satelliteLib-da0748631f5bf7f81de415cc298c402328aca822.js"></script>
</head>
<body class="tundra" style="margin: 0px; overflow:hidden;">
<form name="frmLogOut" id="frmLogOut" method="post" action="/idp/esec/logout.ht">
<input type="hidden" name="CST" id="CST" value="yQiJd0LUsfLawQPn9hibYKYebvjqQN2ek5F3WIO-Q6s"/>
</form>
<form name="pinacleMenuForm" method="post" action="/portal/isc/ITS" target="contentIframe">
<input type="hidden" name="svcnum" value=""/>
<input type="hidden" name="lte" value=""/>
<input type="hidden" name="relayState" value=""/>
<input type="hidden" name="sky" value=""/>
<input type="hidden" id="isLogoutProcessStart" name="isLogoutProcessStart" value="false"/>
</form>
<div id="portal-area">
<div id="newNavContainer">
<a id="logo" class="logostyle" target="_top">
<img src='/portal/shared/images/logo_PINACLE.png?05222010' title='PINACLE Home' />
</a>
<div class="utilitybar">
<input type="hidden" id="isLogoutProcessStart" value="false"/>
<!-- Start of Utility bar -->
<div id="utilityMenu" class="noarrow"><a id='LOUT'
href='/portal/esec/logout.ht~popup=N'">
Log Out</a>
</div>
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<div id="utilityMenu" class="noarrow"><a id='HELP'
href='/portal/isc/ITS?svcnum=615&lte=999&relayState=Admin&sky=n9wMfSLEaF8Tq%2Bq7BKeC%2BKOSkpw%3D~popup=N'">
Help & Training</a>
</div>
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<!-- Quick Links menu -->
<div class="arrow"><span class="top-levelQL">Quick Links</span>
<div class="dropdown">
<div id="utilityMenuQL">
<a id="HOME" href="https://www6.rbc.com/nj00-wcm/~popup=Y" target="_top">
Canada Express</a>
</div>
</div>
</div>
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<div id="cntsMenu" class="arrow" >
<span class="top-levelCNTS">Contact Us</span>
<div class="dropdown">
<div class="contact-separator" id="utilityMenuCNTS"><a id='PNE' href='/portal/isc/ITS?svcnum=110&lte=32&relayState=Normal Login&sky=hFBb%2BFaxIE2mbqyXUPb4QI8ujhw%3D~popup=N'
target="_top">Phone & Email</a>
</div>
</div>
</div>
<!-- End of Contact Us menu -->
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<div id="mcMenu" class="arrow">
<span class="top-levelMC">Message Center</span>
<div class="dropdown">
<div id="utilityMenuMC"><a id='MC' href='/portal/isc/ITS?svcnum=410&lte=999&relayState=managerUser&sky=zUUFoarcvOhT%2BHZsvYhGUxdTrMY%3D~popup=N'
target="_top">View Messages</a>
</div>
<div id="utilityMenuMC"><a id='EVXCN' href='/portal/isc/ITS?svcnum=411&lte=999&relayState=normalLogin&sky=WYvYvPEHQiONA%2FJVJ6Nv2ixnfgc%3D~popup=N'
target="_top">Create Notifications</a>
</div>
<div id="utilityMenuMC"><a id='EVXMN' href='/portal/isc/ITS?svcnum=411&lte=999&relayState=evxMngNotifications&sky=14NR7J0sK%2F%2BOBBwvjZ2KL4sccxE%3D~popup=N'
target="_top">Manage Notifications</a>
</div>
</div>
</div>
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<div id="utilityMenu" class="noarrow"><a id='PROF'
href='/portal/isc/ITS?svcnum=120&lte=779&relayState=Admin&sky=XLwwWwsdoebibPHq17ltTwMaQRY%3D~popup=N'">
My Profile</a>
</div>
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
<input type="hidden" id="homemenuurl" value="/portal/shared/js/dashboard/dashboard.html" />
<div id="utilityMenu" class="noarrow"><a id='HOME'
href='/portal/shared/js/dashboard/dashboard.html~popup=N'">
Home</a>
</div>
<!-- Quick Links menu -->
<!-- End of Quick Links menu -->
<!-- Begin MessageCenter menu -->
<!-- End of MessageCenter menu -->
<!-- Begin Contact Us menu -->
<!-- End of Contact Us menu -->
</div>
<div class="clear"></div>
<div id="mcSecurityCenter" class="securitycenter">
<a href='/portal/isc/ITS?svcnum=-201&tgt=L1BOU1dlYi9zaG93L2NvbnRlbnQvdHlwZS9TZWN1cml0eQ==~popup=N'
target="_top">
<img src='/portal/shared/images/shield.gif'
alt="Security Center" title="Security Center"/></a>
</div>
</div>
<div id="navbar">
<input type="hidden" id="keepaliveuri" value='/portal/modulecontainer/keepmealive.ht'/>
<a class="buttons prev" href="#"></a>
<div id="tabs" class="viewport">
<ul class="overview ui-sortable" id="sortable">
<li class="border-right"><a class="cursor" id='IR' menuId = '11084'
href="/portal/isc/ITS?svcnum=277&lte=999&relayState=normalLogin&sky=M2ePfNeGG85McrNpd8XuyGxkYTg%3D~popup=N" text="Information Repting" onClick="pendoFunction('')" >
<span class="center-align">
Information <br> Reporting
</span>
</a>
<div id="keepaliveind" data="N"></div>
</li>
<li class="border-right"><a class="cursor" id='SRS' menuId = '35'
href="/portal/isc/ITS?svcnum=966&lte=999&relayState=normalLogin&sky=U9HtsOKdAoQPfjSFA2vaeecoieQ%3D~popup=N" text="Spl Rpts Svc" onClick="pendoFunction('')" >
<span class="center-align">
Special <br> Reports
</span>
</a>
<div id="keepaliveind" data="N"></div>
</li>
</ul>
</div>
<a class="buttons next" href="#"></a>
</div>
<div class="navbar-divider"></div>
<div id="blankDivIR" style="height:0px;width:100%">
<iframe id='blankiframeIR' style='width:100%;height:0px'
scrolling="NO" noresize marginwidth="0" marginheight="0" frameborder="0"
src='/ir/irOpeningPage/initialize.htm'>
</iframe>
</div>
<div id="blankDiv" style="height:0px;width:100%">
<iframe id='blankiframe' style='width:100%;height:0px'
scrolling="NO" noresize marginwidth="0" marginheight="0" frameborder="0"
src='/portal/isc/blank.jsp'>
</iframe>
</div>
<div id="pingRequestsDiv" style="height:0px;width:100%">
<iframe id='pingRequestsiframe' style='width:100%;height:0px'
scrolling="NO" noresize marginwidth="0" marginheight="0" frameborder="0"
src='/idp/pingRequests.ht'>
</iframe>
</div>
<div id="alertDiv" style="height:0px;width:100%">
<iframe id='alertiframe' style='width:100%;height:0px'
scrolling="NO" noresize marginwidth="0" marginheight="0" frameborder="0"
src='/portal/isc/blank.jsp'>
</iframe>
</div>
<div id="contentDiv" style="height:87%;width:100%">
<iframe id='contentIframe' name='contentIframe' style='height:100%;width:100%'
marginwidth="0" marginheight="0" frameborder="0"
src='/portal/shared/js/dashboard/dashboard.html'>
</iframe>
</div>
<div id="dialog-confirm" title="Session About To Expire" style="display: none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:12px 12px 20px 0;border-color: #334455"></span>Your PINACLE session is going to expire. Do you want to extend it ?</p>
</div>
<div id="dialog-confirm-non-pnc" title="Session About To Expire" style="display: none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:12px 12px 20px 0;border-color: #334455"></span>Your session is going to expire. Do you want to extend it ?</p>
</div>
</div>
</div>
<!-- Footer tag for Web Analytics -->
<script type="text/javascript">_satellite.pageBottom();</script>
<script type="text/javascript" >var _cf = _cf || []; _cf.push(['_setFsp', true]); _cf.push(['_setBm', true]); _cf.push(['_setAu', '/resources/54334735b2196aff2ba74ad5d5844c']); </script><script type="text/javascript" src="/resources/54334735b2196aff2ba74ad5d5844c"></script></body>
</html>
I was able to determine that the "moreOptions" element is inside of
the iFrame, I edited my original message to pull in the full HTML for
the page. I see that the "IR" element is outside of the iFrame.
To access the elements located inside the tag, we have to find the iframe tag first, then access the elements. You try to use the following code to get elements from the Iframe:
IE.Document.getElementsbyTagName("iframe")(0).contentDocument.getElementbyId("txtcontentinput").Value = "BBB"
IE.Document.getElementsbyTagName("iframe")(0).contentDocument.getElementbyId("btncontentSayHello").Click
[Note] The array index starts from 0. If the website contains multiple iframe tag, make sure using the right array index. Also, you could use the getElementbyId() method to find the iframe tag.
Detail sample code as below:
index page:
<input id="txtinput" type="text" /><br />
<input id="btnSayHello" type="button" value="Say Hello" onclick="document.getElementById('result').innerText = 'Hello ' + document.getElementById('txtinput').value" /><br />
<div id="result"></div><br />
<iframe width="500px" height="300px" src="vbaiframecontent.html">
</iframe>
vbaframeContent.html
<input id="txtcontentinput" type="text" /><br />
<input id="btncontentSayHello" type="button" value="Say Hello" onclick="document.getElementById('content_result').innerText = 'Hello ' + document.getElementById('txtcontentinput').value" /><br />
<div id="content_result"></div>
The VBA script as below:
Sub extractTablesData1()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.navigate ("<your website url>")
While IE.ReadyState <> 4
DoEvents
Wend
'access elements outside the iframe tag and set value.
IE.Document.getElementbyId("txtinput").Value = "AAA"
IE.Document.getElementbyId("btnSayHello").Click
'access elements inside the iframe tag.
IE.Document.getElementsbyTagName("iframe")(0).contentDocument.getElementbyId("txtcontentinput").Value = "BBB"
IE.Document.getElementsbyTagName("iframe")(0).contentDocument.getElementbyId("btncontentSayHello").Click
End With
Set IE = Nothing
End Sub
After running the script, the result as below:

set web content default preferences of portlet freemarker and liferay 7

I read that I can set a default content to display in a portlet into the theme layout, with this code:
<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone") />
<#assign VOID = freeMarkerPortletPreferences.setValue("groupId", "37295") />
<#assign VOID = freeMarkerPortletPreferences.setValue("articleId", "46616") />
<#liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
instanceId="quick_links"
portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet"/>
but when I did this, the portlet display that I need set a web content to display:
I have hardcode the groupId because the web content that I want display was created on another site.
I think you have a typo... check this example (https://dev.liferay.com/pt/develop/tutorials/-/knowledge_base/7-0/applying-portlet-decorators-to-embedded-portlets)
<#assign VOID =
freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId",
"barebone")>
<div aria-expanded="false" class="collapse navbar-collapse"
id="navigationCollapse">
<#if has_navigation && is_setup_complete>
<nav class="${nav_css_class} site-navigation"
id="navigation" role="navigation">
<div class="navbar-form navbar-right" role="search">
<#liferay.search default_preferences=
"${freeMarkerPortletPreferences}" />
</div>
<div class="navbar-right">
<#liferay.navigation_menu default_preferences=
"${freeMarkerPortletPreferences}" />
</div>
</nav>
</#if>
</div>
<#assign VOID = freeMarkerPortletPreferences.reset()>

Resources