How to add pagination for component front end (Joomla 2.5) - pagination

I am new in joomla, i want to know how to add pagination to component for FRONT END, from searching i found only pagination for back end only.

So by default there is no pagination in front-end (at least from my knowledge).
It should work like in the backend.
Adding the pagination from the backend in the front-end is not the smoothest thing on earth but this is how it should work:
Your Model should extend JModelList
In the View (view.html.php) you call the Pagination
$this->pagination = $this->get('Pagination');
At the end in the component template (normally default.php) you will just add:
<?php echo $this->pagination->getListFooter(); ?>
For missing CSS classes add the missing files from the administrator side.
Let me know how it works.

Thanks Valentin !
For more detail, in the View (view.html.php)
class ProjectViewMyProjects extends JViewLegacy{
protected $items;
protected $pagination;
public function display($tpl=null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
.............................................
}
At the end in the component template (normally default.php) :
.................[foreach list of db query]...................[endforeach]
$this->pagination->getListFooter();

Related

AngularJS 2 with .NetFramework 4.6

I'm currently making a web application with Asp.net MVC 5 (.Net Framework 4.6) and AngularJS 2.0 .
I take care the back-end and my friend takes care the front-end.
Now, he sends me 3 js files, 1 html file.
Can anyone help me to import those file to MVC 5 please ?
Thank you,
I´m assuming you are new to MVC...
Create a new MVC project.
Copy your js files to Scripts. (Drag from explorer to visual studio)
The best way to go with js is to make a bundle:
In app_start, open BundleConfig.cs
Create a new Bundle like this:
bundles.Add(new ScriptBundle("~/bundles/mybundle").Include(
"~/Scripts/myjs1.js",
"~/Scripts/myjs2.js",
"~/Scripts/myjs3.js"));
Now to render this bundle, open Views->Shared->_Layout.cshtml
Go to the bottom, find #Scripts.Render("~/bundles/jquery")
Add your bundle: #Scripts.Render("~/bundles/mybundle") Now, your js is available to all pages.
We need to create a controller. Right click Controllers folder -> add -> Controller
Select MVC5 Controller Empty.
Give it the name you like for this page.
You will see this:
public class testeController : Controller
{
// GET: teste
public ActionResult Index()
{
return View();
}
}
11. Right Click the Index in the code -> click in add View
12. VS will open the view. Paste your HTML here.
You are good to go!
Things to keep in mind 1 - ROUTES:
MVC default route (URL) is /controller/Action/id
In the example above, your url will be: /teste or /teste/index because it´s the controllers name.
If not provided MVC uses Home as controller name and Index as action name and id is optional.
So, if your page is the home page for the site put it in the Views -> Home -> index.cshtml
Things to keep in mind 2 - BUNDLES:
Bundles are available for all pages, if you need your js in only one page, to this:
Open your View, go to the bottom of the file and do this:
#section scripts{
<script src="~/Scripts/js1.js"></script>
<script src="~/Scripts/js2.js"></script>
<script src="~/Scripts/js3.js"></script>
}
Things to keep in mind 2 - LAYOUT:
MVC works divides your content into 2 files, stuff common to all pages, like navigation bar, footer, css and js calls reside in:
Views -> Shared -> _Layout.cs
Views are the changeable content in the middle of the page, look for the method #RenderBody() in _Layout.cshtml to find where your view will be rendered.
Maybe you will have to divide your friend´s html to have some in _layout and some in the View. This is quite common.
Good luck and Happy Coding!!
Sure,
Create an ../app folder and drop the js files
The html file you have, I suggest you copy paste its content into a razor view, ../Views/App/MyPage.cshtml
Then create a c# controller that will return that view AppController
public class AppController : Controller
{
public ActionResult MyPage()
{
return PartialView();
}
Like this https://github.com/victorantos/AngJobs/blob/master/AngJobs/Controllers/AppController.cs
Another important note, make sure your router is configured properly, like this
https://github.com/victorantos/AngJobs/blob/master/AngJobs/App_Start/RouteConfig.cs

Sails js render partial view

I'm new in SailsJS so i have a question about rendering partial views.
I've came from .NET world and partial views in ASP.NET MVC are much more clever than in sails. In .NET MVC i can provide some controller as partial view path and this controller will be executed and partial view will be rendered with that controller data.
For example I want to show some account info in the corner of my website. So in .NET i can call partial view, providing controller path, this controller will query account info, provide it to partial view, and then this result will be inserted to main view.
In Sails i can call partial view, but all data (locals) for partial view will be pushed there from main view. So i have to put account information in every controller in application?
How can i solve this problem?
In other questions i've found that I can take username from req.session but it does not solve all cases. How can i show three random topics in page footer for example?
I think you are looking at the wrong place about the partial views.
This is a front-end problem .What I use for such partial views is Angular UI-router . Actually I am not sure if using angular is in the scope of the solution for you,So I'll keep this short . If you feel my method is useful ,you can comment it ,and I'll elaborate further on how to do it .
Depends on the template engine, that you use.
With ejs you can use <%- include('someview') %> or <%- include('someview', { mydata: { foo: bar} }) %>
The latter allows the include file to be called several times with diff data. E.g. <%- include('someview', { mydata: foo }) %> will copy foo (from locals) to the mydata key. This will be added to locals, so all other locals are available too.
As for providing the actual data, you can use a sails service. Just add data to res.locals.myKeyForTheInclude.
You will have to call the service each time.
But you can add it in config/http as a middleware.
middleware: {
myFoo: myService.myFunc,
order: [
...
'myFoo', // before router
'router',
...
],
All that is left is that each template needs the include.
You can not avoid that, only the template knows where the include should be.
But if you use a layout, that maybe it fits into the layout.

Dynamic Menu Navigation In Umbraco Using .Net User Control

I am .Net developer and am looking for example related to creation of dynamic navigation menu in umbraco 7 using .Net user control without using MVC technique and XSLT. I have searched it on google but got not much response on it, examples which i got were using either XSLT or Razor. I have not any experience in MVC and XSLT and looking for technique related to using classic ASP.Net, i.e. without using XSLT and MVC. It will a great help if any one could please provide some useful videos or links with examples which i could refer to.
Thanks
Tarunjit Singh
You should really look into the Razor thing. It just TOO simple not to try!
It looks like c# mixed with some HTML. If you really want to stick to .Net UserControls you might miss out on future versions.
Creating navigation in a usercontrol is very difficult because you have 2 options
you need to write out HTML yourself
create some custom model to some 3th party control
Both of these options will never return the exact html as you wanted. Razor (and xslt) on the other hand will.
If you still want try something in a .Net User control anyway, get an instance of the Umbraco Nodes you want. Let's give an example:
using System;
using System.Linq;
using Umbraco.Web;
public partial class UserControls_TestUserControl : UmbracoUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
var cache = this.UmbracoContext.ContentCache;
var rootNodes = cache.GetAtRoot().First().Children;
foreach (var node in rootNodes)
{
Response.Write("<li>" + node.Name + "</li>");
}
}
}
If you want to call this code, don't forget to add a macro, and insert the macro in your template.
Just in case you would like to explore razor, here is an equivalent:
#inherits UmbracoTemplatePage
#{
var homePage = CurrentPage.AncestorOrSelf(1);
var menuItems = homePage.Children;
}
<nav>
<ul>
<li>Home</li>
#foreach (var item in menuItems)
{
<li>#item.Name</li>
}
</ul>
</nav>
This example can be used as a partial view. And can be put in your (Razor) template using: #Html.Partial("NameOfThePartial")
You have to admit, it's not too hard.

Exception trying to load tab from ajax request using Ext.NET

I'm using asp.net mvc with ext.net and I'm trying to create a set of tabs that load information only when they are selected by the user.
I can manage to load a partial view into a tab/panel using the ContentFromAction functions:
But I can't figure out how to populate a tab/panel only when a tab is selected.
I've based my project on the Ext.NET MVC Examples Explorer version 2.5 code base and this code on the TabPanel > Basic > Ajax Load example found here
I've cut down the example as far as I can to reproduce the problem:
In my view I create the tab and configure the loader (exactly the same as the example project):
Index.cshtml
X.Panel()
.ID("Tab3")
.Title("Ajax Tab")
.BodyPadding(6)
.AutoScroll(true)
.Loader(X.ComponentLoader()
.Url(Url.Action("Ajax"))
.LoadMask(m => m.ShowMask = true)
.Params(new Parameter("containerId", "Tab3"))
.Mode(LoadMode.Html)
)
It correctly calls into my controller (exactly the same as the example project):
Axax_LoadController.cs
using System.Web.Mvc;
namespace Ext.Net.MVC.Examples.Areas.TabPanel_Basic.Controllers
{
public class Ajax_LoadController : Controller
{
public ActionResult Ajax(string containerId)
{
return View("Ajax");
}
}
}
Which in turn displays the appropriate view in the tab after it's been clicked on:
Ajax.cshtml (this works)
#using Ext.Net.MVC
<div>
<p>I am content loaded via Ajax when the tab is selected</p>
</div>
The problem begins if I try to add controls in my view, as follows:
Ajax.cshtml
#using Ext.Net.MVC
#{ var X = Html.X(); }
<div>
<p>I am content loaded via Ajax when the tab is selected</p>
#X.TextField().Text("I am a text field")
</div>
This fails with the exception:
ItemTag validation (_tkn_1): Reference token (init_script) was not found.
If I modify the file Ext call to return Html as follows:
Ajax.cshtml
#using Ext.Net.MVC
#{ var X = Html.X(); }
<div>
<p>I am content loaded via Ajax when the tab is selected</p>
#X.TextField().Text("I am a text field").ToHtmlString()
</div>
It correctly renders the following text in my selected tab:
I am content loaded via Ajax when the tab is selected
<#:item ref="init_script" index="0">Ext.create("Ext.form.field.Text",{renderTo:"App.id534c5fe0f159f3fb_Container",value:"I am a text field"});</#:item><div id="App.id534c5fe0f159f3fb_Container"></div>
I believe that the ext.net code is written by #geoffrey.mcgill on stack overflow so I'm hoping he can help rescue me.
You need to use a PartialViewResult. Please look at these examples.
Partial Content
Partial Items
Personally, I would recommend to follow the Partial Items example. You always can wrap any non-Ext.NET content in an Ext.NET Container. The benefit of this approach is the fact that you don't need to worry about destroying Ext.NET components if you reload the content. Though, anyway, I would recommend to set up explicit IDs for Ext.NET components in a partial view. At least, for top level components.

Yii layout in controller

i'm a new one in Yii :)
I'm trying to generate CRUD structure with Gii and everything ok.
But i'm a little confused about overriding layout path in controller.
public $layout = '//layouts/column2';
How to explain such path, especially "//" part?
Have a look at the documentation for CController::getViewFile(). It explains the // and other view path options.
It means that the template file column2.php has to be found under the default view directory for the application. That is : protected/views

Resources