I need to get the page path in dialog of page properties. I tried CQ.WCM.getPagePath. it works fine when page properties are changed from dialog, but returns path of siteadmin page when the dialog is accessed by right clicking on the page in site admin. Is there any other way to get page path? Thanks in advance.
You can get the selected path using the following code. In case the dialog is accessed from siteadmin, you can use get the selections from the active grid, or if it is accessed via the page, you can use CQ.WCM.getPagePath() method to get the path of the page.
function(comp) {
/* if accessed via siteadmin */
if(CQ.wcm.SiteAdmin.hasListSelection()) {
var grid = CQ.wcm.SiteAdmin.getActiveGrid();
var selections = grid.getSelectionModel().getSelections();
/*Since you can view only properties of one page at a time,
we would be having only one item in the array */
console.log(selections[0].id);
} else { /* accessed via page */
console.log(CQ.WCM.getPagePath());
}
}
The above function can be used for the beforerender event of your dialog.
Related
I am using Bootstrap 5.0.2 as the basis of my website, I finally got the modal to appear on page opening, thanks stack overflow, my aim is to not have the modal appear should the visitor move to another page and then return.
This is the code for running the modal. What do I need to add to make it only function the first time this page is viewed per session?
<script>
window.addEventListener('DOMContentLoaded', () => {
const modal = new bootstrap.Modal(document.querySelector('#myModal'));
modal.show();
});
You would need to implement sessionStorage.
When a user visits the page, we check to see if the sessionStorage contains a value for the modal. If it is the first time they load the page, it would not contain a value as we haven't set anything to it yet. In that case, we show the modal as normal and set a value for the sessionStorage. That way, when the user refreshes the page the value is already set in sessionStorage so the if statement will not run.
window.addEventListener('DOMContentLoaded', () => {
if (!sessionStorage.getItem("modal")) {
const modal = new bootstrap.Modal(document.querySelector('#myModal'));
modal.show();
sessionStorage.setItem("modal", "blah");
}
});
I have a home page that displays results based on some user information. From results page user can navigate to profile page and edit information. After edit information, they navigate back to home page. The problem is, the home page not refreshed with new results. It still shows old results. How can i reload this page with the new data.
home.page.ts:
openProfilePage() {
this.router.navigate(['/profile']);
}
profile.page.ts
onSubmit() {
this.router.navigate(['/home'], {replaceUrl: true});
}
You can trigger a call you need to make to update the info on:
ionViewDidEnter() {
console.log('ionViewDidEnter ');
// call update function
}
ionViewWillEnter(){
//here you check data is changed or not and call your function according to that this method call every time when navigate to home page
}
The main interface for my app is dynamically built based upon whether or not the app has been activated. I created a previous route service that uses Angular’s Activated Route to detect if the main interface needs to be updated without doing a complete refresh.
I opened a window with com.google.gwt.user.client.Window.open()
How to retrieve the title and URL of this new window after navigating in it ?
After openned a new window with "http://www.google.com" and searching "Stackoverflow" the title become "Stackoverflow - Google Search" and the URL change to "http://www.google.com/&q=stackoverflow"
I would like to retrieve these two informations in the parent window.
How do I do it with GWT ?
Example :
private void myMethod() {
Window.open("http://google.com", "Google")
// ... searching "Stackoverflow"
Button b1 = new Button(getTitleOfPopupWindow()); // Stackoverflow - Google Search
Button b2 = new Button(getUrlOfPopupWindow()); // http://www.google.com/&q=stackoverflow
}
Once you open a new window, it becomes a totally different window that your app cannot access - unless you have total control over its contents (i.e. it's on your domain). It would be a huge security and privacy hole if an app in one browser window/tab had access to the information in all the other windows/tabs.
You can let your users open an iFrame within your app and see where they navigate within that iFrame, if your users don't mind it.
If you have a total control over the new window, then you can insert a script in the child page to call the parent page using Window.opener. However, it looks like this is not your use case.
I have the following code to check if my tab is liked by the user:
protected bool IsPageLiked()
{
try
{
var current = ConfigurationManager.GetSection("facebookSettings")
as IFacebookApplication;
dynamic data = FacebookWebContext.Current.SignedRequest.Data;
if (data.page != null)
{
var pageId = (String)data.page.id;
var isUserAdmin = (Boolean)data.page.admin;
var userLikesPage = (Boolean)data.page.liked;
if (userLikesPage)
return true;
}
}
catch (Exception ex)
{
return false;
}
return false;
}
This works correctly when I load my tab initially.
However, if I try and call the same code after changing page within the tab, I get the following error:
{"Precondition failed: !String.IsNullOrEmpty(signedRequestValue)"}
Is there a way I can make this code work after the first page?
I know I can check if the tab is liked on the first page, and put this into a session object or something, but I'd prefer not to do this.
My app itself is MVC 3
Thanks
EDIT
I think what is happening is when I change page (I'm using a RedirectToAction method), it's loosing the signed_request query string, hence the error I am getting.
Edit 2
Not sure the above is what is happening after all, as I can't see any query string values on the initial page? It's still not able to get the signedrequest.
It looks like the signed_request is a form object (Request.Form["signed_request"] returns the string in the inital page, but not the second page).
Page tabs are basically just your app within an iframe on the page, like you've noticed the signed request is POSTED to the tab on page load.
When you change page within the tab the outer Facebook frame isn't reloading so the signed_request is not being re-posted to your tab which is why you can't access it again.
You will need to either pass the signed_request from one page to the next yourself or make sure all links use target="_top" so that the whole page is reloaded each time and you still get the POST.
To define which page you want your tab to load you can use an additional parameter called app_data in the url to your tab, eg
http://www.facebook.com/MY_PAGE?sk=app_MY_APP_ID&app_data=A_STRING_OF_DATA
Your tab will then receive this as part of signed_request, you can grab it and use it to work out which page your tab needs to display.
I have created site navigation in my ASP.net application using SiteMapPath control and its working fine. Now my requirement is that, there is open page in my application which has Radio buttons and based on their selection datagrid is populated from database. I want to save the radio button selection in navigation url so that when I click on that page through navigation url then page will display the data from my selected options.
Any help would be highly appriciated.
Thanks,
Yogesh
I'm not sure that I understand. I propose some other solution (using Session). Add event to radioButton onSelectionChange. When selection change, remember this in Session
Session["name_param"] = some_params;
And in form with dataGrid get event PageLoad with code:
if ( Session["name_param"] != null ) {
var param = Session["name_param"];
// using param to load data to grid
} else {
// something else, maybe default chance for data to grid
}