I'm trying to create a session variable on the home page skin that will return either true or false depending on if the user has previously visited the home page in the current session. I then need to check the value and if this isn't their first time visiting the home page, I need to echo/print javascript.
I've tried
Session("HomePageSeen") = "false"
Session["HomePageSeen"] = "false";
Also, it's a DNN6 site. My understanding is that DNN6 uses C# instead of VB. However, at the top of my .ascx skin file, there's this line of code:
<%# Control language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>
So I'm not sure if I should write this in C# or VB.
I know how I'd do this in PHP and I feel like the same logic would apply here, but I'm no where near as well versed in .Net, VB, or C#.
The skin can be in either language, in whatever version of DNN that you want (the core code switched to C# in DNN 6, but that doesn't affect the language used by extensions). The language for the skin is based on that language attribute in the Control directive
You should be able to get and set a session value using that Session property. Something like this:
<% If Session("HomePageSeen") Is Nothing Then %>
<% Session("HomePageSeen") = True %>
<script>alert('hello');</script>
<% End If %>
Related
I have a problem with calculations. I have a site in vb.net, which connects to a 2002-2003 access database, where there is data with comma as decimal separator, and then creates a dataset. The site is in Italian and is hosted on a server in Italy, and it works fine.
On the output page there are some calculations made in the codebehind page like this (AverageJan is a decimal, dRow is a dataRow, a cell in the the Access database):
AverageJan = (dRow("JanMin")+dRow("JanMax"))/2
In the web.config page, the culture is:
globalization culture="it-IT" uiCulture="it-IT" requestEncoding="utf-8" responseEncoding="utf-8"
I translated the site into French, it is another website but the code is the same. Here, in the web.config, I put the following culture:
globalization culture="auto:fr-FR" uiCulture="auto:fr-FR" requestEncoding="utf-8" responseEncoding="utf-8"
If I open the site from my home (in Italy) it works fine too, but a person from France wrote me: she opened the site with a mobile phone that had the settings in English, and indeed there were some miscalculations. I think the problem lies with the culture, but I don't really understand what happens.
I tried to put the culture in the web.config like this:
globalization culture="fr-FR" uiCulture="fr-FR" requestEncoding="utf-8" responseEncoding="utf-8"
but this is even worse: even from my home, the system cannot calculate the average between two numbers (the result is always 0).
Does someone have any idea on what is going on? Thank you in advance.
Now that my new views start with
#inherits Custom.Hybrid.Razor12
What do I need to do to continue to get access to Dnn Stuff when needed? I've been bouncing around the docs, but haven't spotted anything yet.
Are there compile codes that will let us do things like <### IF DNN ###>?
My specific need right now, and I am hoping someone can offer an example, is we always wrapped our module/View output like this
<div id="viewtype-#(Dnn.Module.ModuleID)">
</div>
And this allowed us to include some very module-targeted (non-leaky) CSS.
<style>
#viewtype-#(Dnn.Module.ModuleID) .navbar{
...
}
</style>
So then this sort of becomes two questions:
How do you do DNN specific things in a View properly?
What is the new-correct way to do the thing in the example above so that it would ALSO work on Oqtane? Do they have a Helper that would provide a unique ID at the same level as the View?
When you are editing a template, there is a menu at the left of the edit window. If you expand the <> you will see all sorts of helpers, DNN and otherwise.
And, the top icon expands to a list of all of the files/views/css that you might want to edit.
Or am I misunderstanding?
Oh, you don't have to do any of the <## xxxx ##> stuff any more. You can just refer to the DNN variables and methode (perhaps preceded by #) and just use them. After all, the template is a mixture of HTML and Razor stuff. The Razor stuff is darned close to c#.
So, you could drop something in like:
[p]
This is an example of using the portal id: #Dnn.Module.PortalID
[/p]
Note: < and > replaced by [ and ] so that they aren't interpreted as tags.
I need assistance with a DNN skin issue. Here's the background.
I have functionality in one of my legacy VB DNN skins that writes the full URL of the parent page. The code is:
<% If PortalSettings.ActiveTab.Level > (0) Then Response.Write(PortalSettings.ActiveTab.BreadCrumbs(PortalSettings.ActiveTab.Level-1).FullUrl) %>
This works fine in my legacy VB skins. However, I am now using a different skin set written in C#. When I apply the above code to the C# skin, it returns the following error message:
Could Not Load Theme: /Portals/_default/Skins/cust08/InteriorSub.ascx,
Error:
c:\inetpub\vhosts\dnnpro.com\httpdocs\Portals_default\Skins\cust08\InteriorSub.ascx(107):
error CS1002: ; expected
I tried tweaking the code, but no success. I'm sure this is an easy fix, but I'm stumped!
Thanks in advance.
The error there is pretty specific You need to put a Semi colon after the code, it is C#
The code you'll likely use would be
<%
If (PortalSettings.ActiveTab.Level >0)
{
Response.Write(PortalSettings.ActiveTab.BreadCrumbs(PortalSettings.ActiveTab.Level-1).FullUrl);
}
%>
I am currently trying to jazz up a SilverStripe site by making the content more engaging. The site is responsive, but all this means currently is that the navigation bar/header snaps to a more mobile friendly style when it hits the mobile break point.
The long and short of it is, my main page.ss is this:
<html>
<head>
<title>$Title</title>
</head>
<body>
$Header
$Layout
$Footer
</body>
</html>
With $Layout rendering a few variations of a basic page. We have a couple of layouts that aim to give our webmaster pages that are a bit more engaging - for example we have an accordion type page that has many accordion section DataObjects, that present the page as an accordion page with the open/shut javascript functionality.
But this is not enough. I want to give the webmaster more flexibility in the CMS to create interesting pages, without me having to create hundreds of different page types.
I'm thinking of creating a module that gets rid of the main $Content field for all pages, and instead inserts a sort of grid system management field. The webmaster can add rows (one DataObject) and then split those rows into sections (another DataObject). The sections will have a content field managed by TinyMCE, just like a page has. Then on the front end I will map these rows and sections to a responsive grid system.
For variations on the sections, I will add classes (a bit like having different page types) that render slightly differently. The sections will have .ss and .css (and possibly .js) to control their own look and feel.
My question is, how have other people approached this problem? Does my idea sound like overkill? Or does it sound like a good idea for a module?
-
For some examples of what I am trying to achieve, this page is a good example:
http://www.wingsforlife.com/en/research/
Content is split up into various sections, which allows for better control when the page is resized. Also throughout the site, content is varied, sometimes it will be in a single column, other times two, which snaps to one column when the window is smaller.
On the home page, if you scroll down, there are 4 links that are presented inside circles, that contain a number and some text: http://www.wingsforlife.com/en/
This is something I can't see being possible inside TinyMCE (which is fair enough as TinyMCE is just a basic content editor, not a web design tool).
Have a look at https://github.com/burnbright/silverstripe-widgetpages for an implementation of using Widgets to compose a webpage. Also https://github.com/g4b0/silverstripe-widget-pages-extension.
this can easily be achieved by replacing the HTMLEditorField that's linked to the Content field in the database by some GridField, managing DataObjects that make up what you might call 'ContentParts'. we've already used this approach in some projects to allow for more rendering flexibility of content elements.
simply tie some DataObjects to your Page class:
private static $has_many = array(
'ContentParts' => 'ContentPart'
);
then, use a GridField to manage them in your getCMSFields:
$gridFieldConfig = GridFieldConfig_RecordEditor::create();
$field_ContentParts = new GridField('ContentParts', 'Content Parts', $this->ContentParts(), $gridFieldConfig);
simplest way to render them in your template is as follows:
<% loop ContentParts %>
<section>...</section>
<% end_loop %>
of course you'll want to have different contentparts, so you might want to create subclasses of ContentPart with their custom fields and use the GridFieldAddNewMultiClass component to add them to your GridField (it's part of the GridFieldExtensions module, to be found here: https://github.com/ajshort/silverstripe-gridfieldextensions)
hth
Is it possible to override the standard 'Create new ' button and 'detail' link in the list view of service cloud console?
I want to show my custom VF pages on click of these buttons/links.(if yes how?)
In addition, any examples to the service cloud API toolkit would be helpful.
Thanks in advance.
Best would be to create separate set of buttons as it's less redirects...
If you want to really override standard ones I think you'll have to use normal overrides (on all buttons) but with content based on Javascript you'd be deciding what should happen.
http://www.salesforce.com/us/developer/docs/api_console/index.htm - Console JS API will be handy.
Make a visualforce page that uses standardController="Your_Object__c". In the content include a reference to the Console API and code similar to this example of isInConsole():
<apex:includeScript value="/support/console/27.0/integration.js"/>
<script type="text/javascript">
function testIsInConsole() {
if (sforce.console.isInConsole()) {
alert("in console");
} else {
alert("not in console");
}
}
</script>
Except you'll be redirecting either to your special pages or to standard "new" and "edit". To force going to original edit mode you can add nooverride=1 parameter in the URL (which is also mentioned in the documentation of URLFOR function).
Normal "new Account" (results in override if specified): /001/e
Force go to your page: /apex/NewAccount
Force go to standard page: /001/e?nooverride=1
So now you have an idea how to detect whether you're in console or not and where to go. Only remaining question is "which window should redirect". Because Console is built on frames you might get different results on using javascript window, location, parent etc. objects. That's a general knowledge how to work with frames in JS so I'm not going to write that up. But I'll include a link to srcUp() function provided by salesforce that you might want to reuse.
I think it's defined only in Console context to be honest so maybe you could ditch the whole isInConsole in favor of typeof srcUp != 'undefined'?
Good luck :)