Build URL/Page links with Scala in Play Framework - clicking to open a new page - scala

I am new to Scala and am trying to build an href link to another page within a website that was already built with HTML and JavaScript. All the links are set up as:
<a href="mypage.html">
I have been researching Scala and understand that it is more routing and configuration than just referring to a another page. I also understand that the other html pages seem to be used as a Single Page Application setup using the #content tag in the main.scala.html page. I may be wrong on this description, but this is how it makes sense to me.
I have set up a new Scala page and am referencing it in my HTML:
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-6 col-ss-12 margbot30">
<a class="services_item" href="#views.html.login3(loginForm)">
<p>
<b>New</b> User Account
</p> <span>Sign up for a user account</span>
</a>
</div>
It does not give me an error, but actually show that login3.scala.html page in that <div> tag. I wanted to have the text clicked and then open that page.
How do I get this link or route to work correctly?
I found this post, but I am still not sure what to do:
Play! Framework - creating simple html links
I appreciate the help and any code examples.

What "#views.html.login3(loginForm)" is doing is invoking the Scala function login3 and the resulting content is being rendered into the page.
Instead of thinking of pages linking to pages, think of pages linking to controllers.
If you have a controller like this:
package controllers;
class FooController extends Controller {
def foo = Action { request =>
Ok(views.html.foo())
}
def bar = Action { request =>
Ok(views.html.bar())
}
}
This is exposed via the routes file as
GET /foo controllers.FooController.foo
POST /bar controllers.FooController.bar
In your views, you then define your hyperlinks using the generated routing:
whatever
So in your case, instead of using
<a class="services_item" href="#views.html.login3(loginForm)">
you would instead have
<a class="services_item" href="#routes.SomeController.theFunctionThatRendersLogin3()">

Related

Add2Any print preview instead of print

I use AddToAny plugin to a Joomla website. I need to replace the code so I can "preview page" instead of "print" (ctrl+p).
I found AddToAny files into /plugins/content/addtoany, but I see no code for print service code
There is no code in the plugin for links generation, unless if you're talking about the css class to add a specific link (see below).
All the links are generated via the AddToAny's js: http://static.addtoany.com/menu/page.js
As you probably already know, all the rendering is generated with classes (powered by the js file above): https://www.addtoany.com/buttons/customize/standalone_services
<div class="a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_google_plus"></a>
<a class="a2a_button_pinterest"></a>
<a class="a2a_dd" href="https://www.addtoany.com/share"></a>
</div>
<script type="text/javascript" src="//static.addtoany.com/menu/page.js"></script>
This means the links themselves are not "generated" in the plugin, so your solutions are whether try to override the plugin via the MVC override plugin or develop your own solution.

Kentico 7 create content placeholder in Portal Master to use in ASCX in inherited page

Working in Kentico 7 on an Ad-Hoc page that inherits from Portal Master. I want to insert some literal script or code right before the </body> tag in the rendered ad-hoc page.
I thought I'd have to do this by editing the portal master and adding the following:
<cms:CMSPagePlaceholder ID="plcBodyEnd" runat="server">
<LayoutTemplate>
</LayoutTemplate>
</cms:CMSPagePlaceholder>
and then in the layout of the Ad-Hoc page do this:
<cms:CMSContent runat="server" id="cntLeft" PagePlaceholderID="plcBodyEnd">
<script type="text/javascript">
ProviderConnections.Transparency.initializeWidget({ });
</script>
</cms:CMSContent>
This worked fine until I went to the design tab on the Ad-Hoc page, where I got the following error:
Object reference not set to an instance of an object.
I don't want to register script blocks. I just want to put text in the Ad-Hoc page that goes there before the </body> tag, which is controlled by Portal Master.
What am I doing wrong?
I'm not 100% sure what you are trying to achieve. Giving an example or attaching a screenshot would be very helpful.
Here are the ways of attaching JavaScript in Kentico:
Through portal engine:
Use JavaScript web part - that gives you an option of choosing where the script should be located
Programmatically from code-behind:
Use CMS.Helpers.ScriptHelper API (wrapper around ASP.NET's ClientScriptManager)
ScriptHelper.RegisterStartupScript() to put the script at the end of the page
ScriptHelper.RegisterClientScriptBlock() to put the script before page's elements
The difference between the two is well explained here.
Programmatically from ASPX markup:
Put your <script> block to a desired location in your .aspx / .ascx files
Evaluate a code-behind variable containing script
<asp:Button ID="btnOK" runat="server" Text="OK" />
<script type="text/javascript">
<%= fieldWithActualScript %>
</script>

Squarespace per page custom navigation links

So I've spent a day on Google, and trying bits of jquery/javascript to do what I'm looking to do and am officially stuck.
I'm building a site using Squarespace, with the Marquee theme applied. I would like to be able to add a custom link in the primary navigation to send users to an alternative language version of each specific page.
But, I'm struggling. Ive found solutions on here that should work, but I don't think I'm applying it right. Ive tried adding a single link to the navigation and using a script on each page (in the code injection point of the head section) point that link somewhere else.
This would mean I have a single link in the navigation (which is standard across the site) pointing users to whichever page I want...on a per page basis. I know there is a solution out there....just can't make it work!
The section I need the link to work from is:
<div id="desktopNav" data-content-field="navigation-mainNav" data-annotation-alignment="bottom left">
<nav class="main-nav" id="yui_3_17_2_1_1450478013910_660">
<div class="nav-wrapper" id="yui_3_17_2_1_1450478013910_659">
<ul class="cf" id="yui_3_17_2_1_1450478013910_658">
<li class="page-collection">
<span>Menu</span>
</li>
</ul>
</div>
</nav>
</div>
None of this can be edited directly though...
I was thinking something like this could work, but I cant work out how to apply it to my situation...
Change href value for a hyperlink
Any help, gratefully received!
I fixed it...using this:
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('a[href*="original.site"]').attr('href', 'http://website.com');
});
</script>
It allows me to point a single link in the navigation (which cant be edited directly) to whatever I want it to go to.

Joomla 1.5 Side Bar Navigation Menu Showing Current Page Possible?

So I am working on Joomla 1.5 and retro fitting an existing website to work with this CMS. I've got most of the templates down and I have created Modules for Side navigation on the internal pages. However, on the original website, php in clauses are used to change the class of the link to show the current page the visitor was on (e.g
<a <?php if ($page=="career_opportunities") echo "class=\"currentpage\""; ?> href="?page=career_opportunities">Career Opportunities</a><br/>
<a <?php if ($page=="locations") echo "class=\"currentpage\""; ?> href="?page=locations">Practice Locations</a>
</div>
is it possible for me to maintain this structure in the new side navigation menu I created in joomla? Do I have to make it HTML customized type Module? Do I need to find a way to capture the current page's ID? Where should I begin?
Thank you in advance
You can do it by using css also which will be much easy for you to handle this using css.

wicket wicket:link

I am trying out the following example. ChangeTextOnClick.html works fine as it is in the same dir as the file that contains the following snippet (WicketLink.html). But HelloWorld.html does not work as it is in another package. How do i refer to page on a different package.
<wicket:link>
<ul>
<li>
Change Text On Click
Back
</li>
</ul>
</wicket:link>
my pages are in the follow dir structure
com.merc.wicket.link.WicketLink.java and .html
com.merc.wicket.link.ChangeTextOnClick.java and .html
com.merc.wicket.main.HelloWorld.java and .html
In Wicket, you would normally reference another html file using a Link in Java to let Wicket generate the href for you. You can mount a Page under a fix URL (called Bookmarkable Link, as they are independent from the user session) or just use a Link.
For a Bookmarkable Link, you would do the following in the init() of your Wicket application class:
public class WicketApplication extends WebApplication{
protected void init() {
super.init();
mountBookmarkablePage("/ChangeTextOnClick", ChangeTextOnClick.class);
mountBookmarkablePage("/HelloWorld", HelloWorld.class);
}
}
With this, you can always reach those 2 Pages under the the URL given.
You can create a link pointing there using this in a MyPage.java:
add(new BookmarkablePageLink<ChangeTextOnClick>("myExampleLink"
,ChangeTextOnClick.class)
and in the corresponding MyPage.html:
<a href="thisGetsReplacedAtRuntime"
wicket:id="myExampleLink">Change Text On Click</a>
If you don 't want the Links to be bookmarkable, you don 't need the mountBookmarkablePage stuff in the init() and use a a Link instead of a BookmarkablePageLink.
Have a look at the Wicket wicki, you will find lots of helpful information there.
It turns out my guess was correct so here it is as an answer:
Wicket uses / as path separator, not ..
<wicket:link>
<ul>
<li>
Change Text On Click
Back
</li>
</ul>
</wicket:link>
is one solution, or using relative paths:
<wicket:link>
<ul>
<li>
Change Text On Click
Back
</li>
</ul>
</wicket:link>
The above answer is perfect.It need not only to be in the different folder in the project,but also it can be anywhere in the folder in the system.Still it possible to refer that file,if the configuation is done correctly in WicketApplication file.