DotNetNuke. How to get current url or ID of page (and frontpage)? - dotnetnuke

I`m use my custom template. In file CustomTemplate.ascx need to control somethings elements.

If your control inherits from PortalModuleBase you will have a property called "TabId" that will give you the id of the current page.
To get the URL for that page you can use DotNetNuke.Common.Globals.NavigateUrl(TabId);
To get the URL for the homepage, you can use PortalSettings.HomeTabId and the same NavigateUrl Method.

The current Url is also obtained by using the Context.Items("UrlRewrite:OriginalUrl"). This is the Url the page was requested with (which is different to the Request.Url or Request.RawUrl value, which is the rewritten Url.

Related

Redirect to an external page from a specific article - Drupal 7

I'm very new with drupal.
I have a blog, List of posts.
I need redirect a specific post to a specific external webpage, Is this possible ?
By example: I need to redirect the post (with the arrow red) to www.facebook.com/somePage. (if it's possible in other tab)
But the other posts should be redirect normally to its internal pages.
In this moment I have this configuration:
Any suggestions?
Method 1
Add a URL Redirect pointing from the 'node/#' URL to your external URL.
Render View as you have it now, and when you click the article Title it'll send you to the external page.
Method 2
Install the 'Link' module.
Add a 'Link' field to your Content Type. Configure the link field to open links in a new window, and so on.
Add that new field to your View. Set it to not appear in display, so it can be used later. Move this link above your Title Field in the View, because the order matters.
Edit the Title field settings and use the Link field value as a Token for the Title field.

Change href of Live Status link in Wagtail Admin

I made a one page scrolling site using wagtail. I have a homepage model and everything else is child pages such as about us, events, etc. On the admin page it creates a slug with the title of the child page which is what the live status link uses. For example it is <a href="/about-us/">. Is there a way to change the live status link at all?
The page URL is constructed by calling the get_url_parts method on the page model - by overriding this method, you can customise the resulting URL:
http://docs.wagtail.io/en/v1.13.1/reference/pages/model_reference.html#wagtail.wagtailcore.models.Page.get_url_parts
http://docs.wagtail.io/en/v1.13.1/topics/pages.html#customising-url-patterns-for-a-page-model
Normally, if you're overriding get_url_parts, you'd want to make a corresponding customisation to your site's URL routing behaviour, to ensure that the page is actually available at the URL in question; this can be done with RoutablePageMixin. In this case, though, it sounds like you're just using these subpages as placeholders for page content, and aren't bothered about them being accessible at their own URL - so you can get away with simply returning '/' as the page path:
class MyChildPage(Page):
# ...
def get_url_parts(self, *args, **kwargs):
url_parts = super(MyChildPage, self).get_url_parts(*args, **kwargs)
if url_parts is None:
# in this case, the page doesn't have a well-defined URL in the first place -
# for example, it's been created at the top level of the page tree
# and hasn't been associated with a site record
return None
site_id, root_url, page_path = url_parts
# return '/' in place of the real page path
return (site_id, root_url, '/')
I ran into this question when using Wagtail as a headless CMS for a Gatsby site. As I do use the URLs generated by Wagtail to structure the Gatsby site, redefining the get_url_parts method does not help me. I do want to keep the page URL as is and use a different host when clicking on the "View Live" or "Live" button in the admin.
I found that overriding the serve() method of the pages that you want to be served by a different host allows you to do just that.
from django.shortcuts import redirect
class BlogPage(Page):
...
def serve(self, request):
site_id, site_root, relative_page_url = self.get_url_parts(request)
return redirect('http://localhost:8001' + relative_page_url)
In the code above, the serve method of the BlogPage model is overridden to use the request and the get_url_parts method to extract the requested relative_page_url (that is relative to the site root -- in development that would be http://localhost). Since my frontend keeps the same URL structure as the Wagtail site, I just use the extracted relative_page_url and combine it with the host of the frontend (in this development case localhost:8001) and return a redirect response (generated with django.shortcuts.redirect) to that full URL.
It probably makes sense to turn this override into a mixin and a setting, so it does not have to be defined on every page model and the redirect host can be differentiated between environments.
You could also use the same logic of overriding the serve() method to redirect to any other location you may choose.

Generating random URL in AngularJS

I wish to see if it is possible to generate a random link each time an admin visits the admin page.
for example: instead of having: "".com/admin, there would be "".com/a93k, "".com/9dik. The page stays the same but just so the end-user can't access the page from the address bar.
Thanks as I am new and do not know how I can implement this.
In .config of your app put something like
window.adminHash = Math.random().toString(36).substring(2,6);
In your routing
url: '/' + window.adminHash
Then you can use "window.adminHash" if you want to redirect to your route, which will change every time you refresh the page
You can add www.test-example.com/admin/{provide some ID}
And If there isn't ID provide discard that URL, if it is provided you can make discrimination.

In Angular how to change the route template using a controller function?

When loading the url at first, I need to display the initial template. But after clicking a link, I need to
Get it's href value (It's the current template url with some extra params)
Send the new url with params to the server
Get the new template (The server will send a new template with new data)
Change the view accordingly (Update the whole page)
I have managed to complete the first task. The 4th task is the real problem. Changing the route's template using the function which gets called when clicking the link (With ng-click). How can I do it?
All you need to do in order to replace current template with the new one is basically two lines of code. Namely:
update current $templateCache for the currently used template;
reload current route.
It could look something like this:
var content = '<h2>New content loaded previously</h2>';
var templateName = $route.current.templateUrl;
$templateCache.put(templateName, content);
$route.reload();
Check the simple demo: http://plnkr.co/edit/V5AG0UXS3b8wBwxrz7qO?p=preview
To get the URL of your current template :
$route.current.templateUrl
You can try to set template value directly (never test)
$route.current.templateUrl = "http://myrul.tld";
You can see the doc at https://docs.angularjs.org/api/ngRoute/service/$route

Salesforce: Launch S-Control in a new window from VisualForce

I'm writing a VisualForce page to replace an old legacy S-Control.
Originally the Custom S-Control was launched from a Custom Button, and it opened in a new browser window (The S-Control is type HTML, and the Custom Button has Behavior: Display in new window)
For certain old records, I want to do a similar thing from VisualForce.
So: Do HTML S-Controls have a URL that I can launch using a link? In which case, how do I figure out the URL?
Or:
Is there a way of embedding 'Custom Buttons' (that is, the buttons defined in "Setup->Customise->Account->Buttons and Links") into VisualForce pages? If so, I can embed the existing button that knows how to open the S-Control
Or:
Can you suggest some other way of doing this? Key features: Open an S-Control in a new window from VisualForce.
Thanks
Got an answer from this forum post courtesy of aballard:
Basically, the !Urlfor() function can be used to get the URL of an S-Control. So, you can use an outputLink like this:
<apex:outputLink value="{!UrlFor($SControl.my_scontrol_name)}"
target="_blank">Show SControl</apex:outputLink>
If you need to pass an object ID to the S-Control, you can add a second parameter that calls a propery on the custom controller, e.g:
<apex:outputLink value="{!UrlFor($SControl.my_scontrol_name, AccountID)}"
target="_blank">Show SControl</apex:outputLink>
... where AccountID is defined on the custom controller as public string getAccountID()
See also this blog post at SalesforceSource for more info on the UrlFor function.

Resources