I want to make different panel for administrator. I created a folder 'Admin' and I put in there index.php, and folder 'lib' with Frontend.php and Auth.php. In admin panel's pages I want to make use of models, templates etc from my main folder. How can I add this to path finder? Folder structure
MainSite
Admin
lib
Frontend.php
Auth.php
index.php
config.php
atk4
atk4-addons
lib(Models which I want to use, Forms ect, Frontend.php, Auth.php)
pages
templates
config.php
index.php
Add this into your application init()
$this->addLocation('..',array(
'php'=>array(
'lib',
'atk4-addons/mvc',
'atk4-addons/misc/lib',
),
'template'=>'templates',
'mail'=>'templates/mail', // if you want to share mail templates
))->setParent($this->pathfinder->base_location);
Also be sure to use
$config['atk']['base_path']='/atk4/';
and your index.php needs to include '../atk4/loader.php';
Related
So, I've created a bog-standard Blazor Server App using dotnet new blazorserver. Opened the solution in VS and run it.
Fine.
If I add a new folder, say Components and add a new Razor Component in that folder - Component1.razor - then in my index.razor page I add a using statement to point at my Components folder and the mark up to include the component itself and run the app, the index page shows, but there is no sign of my component. Further looking at the source of the rendered HTML, I see an empty element <component1></component1>
If I move my new component to the Pages folder and rerun the app, the component renders properly.
If I create a sub-folder under Pages and move my component to there and rerun the app, the component fails to render.
Am I doing something wrong? Am I expecting too much? Should I be able to have a structure that means I don't have to have every single component in a single folder?
I think you missing the point of _Imports.razor. You can put your pages anywhere they will be found by the #page "" attribute. If you want your components to be available either put a reference to their folder via the _Imports.razor or use the #namespace attribute/directive to override the namespace from folder its is in to another that is being imported. There is nothing special happening here. The template puts a using statement in for the "Shared" folder. This is why App.razor in the root folder has access to them.
Example _Imports.razor (From a project with name/default namespace of PolymorphicApi)
...
#using PolymorphicApi
#using PolymorphicApi.Shared
If you do not want to use _Imports.razor, you may not want to make all your components available. You can use #namespace in the component. This is the same as overriding the default namespace in a .cs file.
Example :
#namespace PolymorphicApi
A component using this statement could be in any subfolder and will be available as the root namespace is already imported.
As a side note: _Imports.razor can be thought of as a chunk of razor statements that will be imported into all razor components in that folder down. You do not have to use it just for namespaces. For example you can use an #inject statement. I do this to have Localization in every component by default.
I want to my html template in Prestashop 1.6 framwork
prestashop in which location place css for custome design
Your template folder is located in root/themes/default-bootstrap/
There you have your .tpl like header.tpl, footer.tpl and many others.
If you want to edit a module .tpl file you go to root/themes/default-bootstrap/modules and search for the module you want
Example: Cart located in header you can edit the html by going to root/themes/default-bootstrap/blockcart/blockcart.tpl
If you want to add custom CSS to your template you can add css to your global template file located in: root/themes/default-bootstrap/css/global.css
I have two themes' folders called Default and New in Views folder. These folders are included .cshtml extension files. I want to use these folders as theme option. How can I do theme settings in global.asax?
Install bootstrap through visual studio Manage Nugget Packages and you can utilize free themes available. Lot of free themes are available in https://bootswatch.com/. Download a CSS from the mentioned link and replace the one in your bootstrap CSS folder. Hope this helps...
EDIT
Actually in Asp.Net MVC Global.asax has nothing to do with setting themes. Current theme in MVC is decided by the styles specified in _Layout.cshtml file. Usually this file lies inside Views\Shared path. The _ViewStart.cshtml which lies directly under Views folder decides which layout should the view use.
Approach 1
If we require some other layout for certain views we can add another _ViewStart.cshtml inside the folder where those views exist and specify the path of _NewLayout.cshtml in it. The views will automatically get the new layout/theme while you render it.
Approach 2
Use a logic and set your layout/theme accordingly as shown below in /Views/_ViewStart.cshtml file,
#{
if (this.User.IsInRole("Admin") || !this.User.Identity.IsAuthenticated) {
Layout = "~/Views/Shared/_Layout.cshtml";
} else {
Layout = "~/Views/Shared/_LayoutUser.cshtml";
}
}
I have "test" website on IIS and "sub1" sub-application within it.
When I request domain.com/sub1, IIS processes sub-application sucessfully.
Some of URLs in code are relative, and when I have something like this in code /component/test, application requests following url domain.com/component/test instead of domain.com/sub1/component/test.
What do I need to change in order to make relative URLs to be valid.
in your code, use #Url.Content("~/") or <% =Url.Content("~/") %> to get to the relative root of the application.
Or, sometimes, you can get away with prefixing with ~/, but generally only with js and css files in your layout
note: the # is for razor view engine, and the <% %> is for aspx view engine, you didn't specify which you were using
EDIT: (based on comment from OP)
CSS should be relative from the directory your CSS is hosted, you can use ../ to traverse directories. For your JS, can you edit those files? I would define a SITE_ROOT variable (above all js files) in your layout and then reference that variable from within your JS files
example: var SITE_ROOT = '#Url.Content("~/")';
then prefix your calls in the JS file with SITE_ROOT + '/relative_url'
I am putting my ERB files in app/view. The problem is that sometimes I make mistakes when including CSS and JS files. I refer to them as "js/include.js" or "css/default.css" instead of /js/include.js and /css/default.css
However, these files are located in the public directory not the app/views directory so as a result the page breaks.
Is there a way to change the default behavior so that it looks in public folder whenever I refer to these files relatively?
If you stick with the Rails conventions you'll save yourself some grief. Use stylesheet_link_tag and javascript_include_tag in your layouts. And don't scatter css and js includes around your views. Use custom layouts instead.
For example, if you have an admin interface with a different look and different behavior you could add app/views/layouts/admin.html.erb. Then, in AdminController specify that it should use the admin layout. You can also specify the layout at the controller action level if you need to.