Paths to differents files in one view - Joomla - php

I'm trying to put a link in a component's view file (default.php) to another file in the same view (default_formulaire.php) as you can see below:
But I really don't know how to access it in PHP.
I know that the default.php file's url is:
index.php?option=com_multicontact&view=reclamation
but I don't know that of default_formulaire.php.
Thanks for any help :)

The link to any view in Joomla is the following:
index.php?option=com_componentname&view=viewname&layout=layoutname
However, if the layout is omitted from the URL, then it is assumed that it is set to default. So, the following URL:
index.php?option=com_componentname&view=viewname
Will mean that the layout is default, which means that the default.php file will be loaded.
So, in your situation, the URL to load the default_formulaire layout will be:
index.php?option=com_multicontact&view=reclamation&view=default_formulaire

If you need to access a different layout in joomla then you need to add a layout value in joomla url like index.php?option=com_multicontact&view=reclamation&layout=default_formulaire

Related

Codeigniter posted double link in address bar when clicking href

help me with this code.
<< Kembali menghitung
when i click the link it posted double like :
http://localhost/belajarci/index.php/calculator/localhost/belajarci/index.php/calculator
ive tried to remove the href values but the page not refered to the home, its only change another value in my code.
It's right it's redirecting on double url becasue of you need to include $this->load->helper('url') in your file / controller constructor or use url helper in autoload.php
Also do two things in your configuration:
Check the .htaccess file in project becasue may be you have set there any url redirect.
Check in config file for base url what you have set there.
You are getting this URL:
http://localhost/belajarci/index.php/calculator/localhost/belajarci/index.php/calculator
Because you need to include $this->load->helper('url') in your file / controller constructor or use url helper in autoload.php
After loading url helper your URL will work as you need.
You can also follow the CI User Manual: https://codeigniter.com/userguide3/helpers/url_helper.html

URL path with universal header is not working

I have three pages on my localhost 1 is my index page,2 is my universal header page which is under includes folder of and 3 is my html file which is under html folder.The header file is included in both the index file and html file like that...
for index.php-include("includes/header.php");
for html.php-include("../includes/header.php");
and my header has the link of index.php page that is (./index.php)
Now my questions is that when i open my index page and click on link of index page from my header it takes me to same index.php page but when in open html.php page and then click index.php page link from header it does not go to index.php page but it goes to this page-
(localhost/educational%20website/html/index.php) how to solve that.
And i also want to know that write now i am on localhost but when i make my site live is there any need to change the paths because i am making around 150 pages with your technique plaese so please answer me that kind of technique that is used for both localhost and on live
Your are including paths relatively, use a (absolute) base path in your index.php to fix this:
include_once($_SERVER['DOCUMENT_ROOT'].'/includes/header.php');
One way is to define a variable or a constant for the site's url in the header.php file. Then in all your other pages, you could just use this variable/constant when you need to mention the other urls.
Eg(put this as first line in your header.php file):
define('SITE_URL', 'http://localhost/educationalwebsite');
Here, we have defined a constant named SITE_URL. Then in other pages, you are already including this header file. Isn't it? So, this constant will be available in your index.php, html.php and other pages.
And suppose for a link in your html.php file(to point to the index.php), you could use it like this:
Home
If you want to include link to the html.php file residing inside html folder, it would be like:
HTML
By using this way, if you are uploading the whole site to a live server, you only need to change one line, ie. the first line in header.php, where we have defined the SITE_URL constant. Just change it's value to the new URL of the home directory of your website.
Hope this helps

Get location of view passed into laravel view composer

Is it possible to get the location of a view that is passed into a Laravel view composer?
View::composer('*', function($view) {
// I want to find out the location of the view file here
// e.g. master.something.header
// then add this to an array
$loadedViews = View::share("loadedViews");
$loadedViews[] = $thisViewName;
});
The reason is that I want to have a variable that will be shared between views and contain an array of all the views that are loaded. Any css and js files will be located in directory structure that matches the views one.
This means I can then have a css and js view which then include the required css and js files for the views on the page. All css and js will be directly linked to a specific view.
If there is already a way to do this, or a way to get a list of loaded views, please let me know!
$view->getName() was the answer that I wanted.
$view->getPath() is the actual path to the file.

how to add stylesheet to my layout and pass values from view to layout

I am using zend framework.
My structure is (only included files and folders needed for this question):
application
>configs
>controllers
>forms
>images
>layouts
>scripts
>layout.phtml
>models
>styles
>style.css
>views
>scripts
>index
>index.phtml
Bootstrap.php
docs
library
logs
public
test
I have got the layout working properly. However, I want to ask a couple of questions in order to get my set up perfect for the way I want it.
Is application>styles a good place for the stylesheet to be? If not what's the recommended?
How do i add the stylesheet to the layout?
In my layout I have a title tag : <title>Text</title>. How do I pass values from my controllers to it?
Stylesheets need to be accessible from the browser, so typically you will put these somewhere in the public directory, such as public/css
There are several ways, including placing rel tags in your view/layout, but my preferred option is to use the viewHelper within your controller:
$this->view->headLink()->setStylesheet('/css/style.css');
Then your call to headLink() in the layout file will automatically include the stylesheet.
The way I have done this is to use the Zend_Registry in the past. There may be better ways.

How to switch layout files in Zend Framework?

I'm sure it's a simple one-liner, but I can't seem to find it.
How can I use a different layout file for a particular action?
Update: This worked for me, thanks!
// Within controller
$this->_helper->_layout->setLayout('other-layout') //other-layout.phtml
//Within view script
<?php $this->layout()->setLayout('other-layout'); ?>
From inside a Controller:
$this->_helper->layout->setLayout('/path/to/your/layout_script');
(via these docs)
EDIT: I should mention that the path is relative to whatever your layout directory is (by default, it's application/layouts/scripts/)
You can also use like this
// Within controller
Zend_Layout::getMvcInstance()->setLayout('layout_name');
//Within view script
<?php $this->layout()->setLayout('layout_name'); ?>
Your layout must be in /layouts/scripts/ folder, otherwise you need to specify the path also. No need to write .phtml, just name of the layout

Categories