We have found another great use for the DotNetNuke Announcements module and jQuery. Now, we can use it to create a dynamic accordion. In this post, we will show you how to create an announcement with accordion in DotNetNuke. In case you missed it, this is the second time that we have gotten the DotNetNuke Announcements module and jQuery together. See our previous post on how to create an announcement in DNN with a slider.
This time, we needed to create a solution where we could have a jQuery accordion yet it could be easily updated by the client. So, we thought about the different core modules that were available and picked the announcements module due to the ability to easily template it out. Now, if only the DNN Blog module were fully template driven. This module has spots to place a header, repeatable item, alternating repeatable item, separator, and footer. We will be using only the header, item, and footer.
2. Go to the Module settings.
3. Scroll to the bottom part of the page under Announcement Settings and enter the following code as labeled:
Header Template – (start the wrapping div)
<div id="accordion">
Item Template – (title and body of accordion)
<h3><a href="#">[TITLE]</a></h3> <div>[EDIT][DESCRIPTION]</div>
Footer Template – (end the wrapping div)
</div>
Note: the title can be in whatever header size you wish – ex. h1, h2, h3…
Note: the [EDIT] token MUST NOT be in the heading (e.g. h3) or you won’t be able to edit the item.
Optional: you can put the [IMAGESOURCE] token in with the [DESCRIPTION] token, if you would like to have an image associated with it.
1. First of all you will need to bring in the jQuery.
2. Go to the Page Settings
3. Expand Advanced Settings
4. Place the link to the jQuery UI Theme CSS in the Page Header Tags text box:
<link href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
5. Go to the Module Settings > Announcement Settings and place the following code in theHeader Template ahead of the div you placed in there earlier.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script> <script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.ui.accordion.js"></script>
6. In the Footer Template, place the jQuery from the jQuery secont below after the end of the wrapping div.
7. Place the following code below the jQuery reference files that you just placed in theModule Settings > Announcement Settings > Footer Template:
<script type="text/javascript"> $(document).ready(function(){$("#accordion").accordion();}); </script>
Note: the ID of the wrapping div, must match the div being called in the script.
This should be the code after all is said and done:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script> <script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.ui.accordion.js"></script> <div id="accordion"> <h3><a href="#">[TITLE]</a></h3> <div>[EDIT][IMAGESOURCE][DESCRIPTION]</div> </div> <script type="text/javascript"> $(document).ready(function(){$("#accordion").accordion();}); </script>
Finally, add some entries to your announcements module and there you have your accordion announcements module! Enjoy!
ASPHostPortal.com
ASPHostPortal.com is Perfect, they have a suitable hosting plan for a starter in DotNetNuke Hosting. ASPHostPortal is the leading provider of Windows hosting and affordable ASP.NET Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.
HostForLIFE.eu
HostForLIFE.eu guarantees 99.9% uptime for their professional DotNetNuke hosting and actually implements the guarantee in practice. HostForLIFE.eu is the service are excellent and the features of the web hosting plan are even greater than many hosting. HostForLIFE.eu offer IT professionals more advanced features and the latest technology. Relibility, Stability and Performance of servers remain and TOP priority. Even basic service plans are equipped with standard service level agreements for 99.99% uptime. Advanced options raise the bar to 99.99%. HostForLIFE.eu revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24×7 access to their server and site configuration tools.
DiscountService.biz
DiscountService.biz is The Best Cheap and Reliable DotNetNuke Hosting. DiscountService.biz was established to cater to an under served market in the hosting industry web hosting for customers who want excellent service. DiscountService.biz guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability. DiscountService.biz has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch. DiscountService.biz is devoted to offering the best Windows hosting solution for you.