I have a post with Thumbnail and Attachment. I'm using CarrierWave gem and it looks like uploading works. I can see the files in public/uploads folder and I can see the array in DB, but when it comes to listing in the view, it won't display the images but file names. What am I missing? I can display the thumb image as seen.
<%= image_tag #post.image_url.to_s %>
<% #post.attachment.each do |attachment| %>
<%= image_tag attachment.url.to_s %>
<% end %>
It looks like it is adding this %5B%22 and %22%5D that messes the correct path.
It looks like the Array doesn't loop.
<%= #post.attachment.count %>
returns
1
Related
Whenever I try to make a custom skin object in Admin/Skins folder or Admin/Containers folder, I get the error
Uncaught ReferenceError: jQuery is not defined
I'm trying to add a bootstrap link skin object to be used in the template. DNN Newbie here!
<%# Control Language="C#" AutoEventWireup="false" Inherits="DotNetNuke.UI.Skins.Skin" Codebehind="Button.ascx.cs" %>
<%# Register TagPrefix="dnn" Namespace="DotNetNuke.UI.WebControls" Assembly="DotNetNuke.WebControls" %>
<asp:button id="btnButton" runat="server" cssclass="Normal" enableviewstate="False" MouseOverCssClass="LabelEditOverClass"
ToolBarId="titleToolbar" LabelEditCssClass="LabelEditTextClass" EditEnabled="True" EventName="none" LostFocusSave="false"></asp:button>
<DNN:DNNToolBar id="titleToolbar" runat="server" CssClass="eipbackimg containerTitle" ReuseToolbar="true"
DefaultButtonCssClass="eipbuttonbackimg" DefaultButtonHoverCssClass="eipborderhover">
<DNN:DNNToolBarButton ControlAction="edit" ID="tbEdit2" ToolTip="Edit" CssClass="eipbutton_edit" runat="server"/>
<DNN:DNNToolBarButton ControlAction="save" ID="tbSave2" ToolTip="Update" CssClass="eipbutton_save" runat="server"/>
<DNN:DNNToolBarButton ControlAction="cancel" ID="tbCancel2" ToolTip="Cancel" CssClass="eipbutton_cancel" runat="server"/>
</DNN:DNNToolBar>
Edit:
I'm trying to create various skin objects like button, title tags, body tags, which take in our CSS styling. So the Marketing department can just drop it to a location, edit the text/link of the button or edit the text in title, etc.
Looking a bit further, DNN does NOT load jquery automatically. You need to set up your custom skin to load it.
See: https://www.dnnsoftware.com/wiki/client-resource-management-api
The short answer to your question is that you can do all of this using the user control DnnJsInclude. Note that there is also a DnnCssInclude control.
As I understand things (from the referenced item), these load the js and CSS files only if they have not yet been loaded.
If you are looking for a model for a DNN Theme, have a look at nvQuickTheme on GitHub.
Thanks to Will Strohl for pointing me in the right direction ...
I am working on building dnn9 multilingual site. I put language selection dropdown in theme.
To show dropdown in theme I am using this code:
<% if Localization.ActiveLanguagesByPortalID(PortalSettings.PortalId) > 1 Then %>
<dnn:LANGUAGE runat="server" ID="LANGUAGE1" ShowMenu="True" ShowLinks="False" />
<% End If %>
Now it shows long language names, like that: English (United States). How can I make it show 3 latter language name, like ENG, instead?
I use the following:
<dnn:LANGUAGE runat="server"
ID="dnnLanguage"
ShowLinks="True"
ShowMenu="False"
ItemTemplate='<span class="Language" style="text-transform: uppercase;">[CULTURE:THREELETTERISOCODE]</span>'
AlternateTemplate='<span class="Language" style="text-transform: uppercase;">[CULTURE:THREELETTERISOCODE]</span>'
SelectedItemTemplate='<span class="Language selected" title="[CULTURE:NATIVENAME]" style="text-transform: uppercase;">[CULTURE:THREELETTERISOCODE]</span>'
/>
That displays links with the three letter ISO-Code, and a popup with the native name when hovering over them.
There is no need to check whether there is only one language or more, as the skin object is hidden automatically when only one languge is activated, or the current page is not translated (or the translations are not published) yet.
Is there a way to trace an object in to the screen ?
I am coming from rails where you can do
<%= debug #var %>
Is there something similar to angularjs ?
console.log(some_var) will print the object to your browser's console.
Better yet, use Firebug or Chrome Inspector and debug with breakpoints.
use {{ var }} on your html page, then set the var in your controller as $scope.var.
I'm trying to get it right with my unix dates in an underscore js template.
In my template I have two unix dates coming from a backbone view that initialises this current template and passing the two dates as arguments.
In my template I now need to compare the two dates and get how many days it is between them. I cant do that in my view. I need to do it in the underscore template.
I'm using moment.js.
<% collection.each(function(model,index) { %>
<%
uploaded = moment(new Date(model.get("uploaded_date")))
servertime = moment(now) /*now is passed in as a variable since its not in the collection*/
%>
<p>
<%= uploaded.diff(servertime, 'days') %>
</p>
<% }); %>
I'm trying to use the diff() but all I get back is "0"
When I print the actual date variables I get the correct unix dates.
Anyone knows hows to do this?
I tried this code and it's working :
var uploaded = moment(new Date(1391185930000));
var servertime = moment(new Date(1390321930000)); // now at the date I wrote that example :)
alert(uploaded.diff(servertime, 'days'));
First try to add a ';' at the end of the two first lines of code.
What your 'now' variable looks like ? Have you tried this 'var servertime = moment();'
I am using dotnetnuke version 5.4. I want to display a link after the terms of use and privacy statement (at the bottom).
This link should be displayed only after a user logged in. Is there is any way to do this? I know how to add a link to the skin.ascx file, but I don't know how to identify whether a user is logged in or not.
In your skin, just add the following in the appropriate place.
VB.NET
<% If Request.IsAuthenticated %>
[Logged in]
<% End If %>
C#
<% if (Request.IsAuthenticated) { %>
[Logged in]
<% } %>
This will show the "[Logged in]" text only if the user is logged in.
The easiest thing would probably be to put the link in an HTML module that is in the footer pane and set it visible only to registered users, and visible on all pages.
<% If HttpContext.Current.User.Identity.IsAuthenticated=True Then %>
<!-- put your stuff here -->
<% End If %>
Stick that in your skin, that should do it.