Codeigniter: form_open gave invalid function URL - forms

I used this function to start a form:
echo form_open('email/send');
and after viewing the source I found that form_open returned duplicated index.php :
<form action="http://localhost/ci/index.php/index.php/email/send"
Note:
I tried keeping only this line of code in the page, but still gave me the same result
Edit1:
Base url : $config['base_url'] = 'http://localhost/ci/index.php/';

What is your index_page configuration item set to? If your base_url and index_page configuration items both include "index.php" then I imagine form_open() would duplicate it.
Change your application/config/config.php to:
$config['base_url'] = 'http://localhost/ci/';
//...
$config['index_page'] = 'index.php';

Related

How to use Sitename in Constants as a default value in TYPO3?

I want to set the Sitename in Constants by default, so I can use this settings.variable in my Fluidtemplate.
I found in another post here on stackoverflow:
DB:sys_template|1|title
GLOBAL:TYPO3_CONF_VARS|SYS|sitename
But if I use this in my constants.ts like this:
# cat=plugin.tx_rmnavigation/01_NaviSettings/a; type=string; label=testing sitetitle
testsitetitle = DB:sys_template|1|title
OR
# cat=plugin.tx_rmnavigation/01_NaviSettings/a; type=string; label=testing sitetitle
testsitetitle = GLOBAL:TYPO3_CONF_VARS|SYS|sitename
AND in my setup.ts:
testsitetitle = {$plugin.tx_rmnavigation.settings.testsitetitle}
I get only the text not the value of the "variable" see this picture Constant Editor...
How can I use the Sitename in Constants as a defaultvalue?
Edit
I forgot to say, perhaps it's important for this issue, I try this here in both files:
plugin.tx_rmnavigation {
settings {
..
}
}
You have to assign your constant to a content object's data property (see https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/ContentObjects/Index.html and https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/Functions/Stdwrap/Index.html#data) to get it resolved:
testsitetitle = TEXT
testsitetitle.data = {$plugin.tx_rmnavigation.settings.testsitetitle}
And I would prefer your second variant for the constant definition because it uses the value from the current template record:
# cat=plugin.tx_rmnavigation/01_NaviSettings/a; type=string; label=testing sitetitle
testsitetitle = GLOBAL:TYPO3_CONF_VARS|SYS|sitename
But the first one should also work if you use colons instead of pipes:
testsitetitle = DB:sys_template:1:title
If you have a multi domain page the query to DB:sys_template:1:sitetitle might not work, as the 1 is the UID, not the PID of the root node of your template. But TSFE to the rescue!
In the context of your page call, the TSFE already has the sitetitle from the backend template loaded.
If you for example want to output a og:site_name, you can access the value by using:
og:site_name = TEXT
og:site_name {
data = TSFE:tmpl|sitetitle
attribute = property
}
This way no additional database queries are needed and it will work on multi domain, multi root node pages.
Thanks for your suggestions. I found a solution with your infos.
Honestly I think this doesn't works in Constants, because the both methods are readonly.
So I found a working solution for my Issue: I need that Variable only for read in my Templates, so I create a new Typoscript File libs.ts and included this with:
# Include Libraries
<INCLUDE_TYPOSCRIPT: source="FILE: EXT:rm_navigation/Resources/Private/TypoScript/libs.ts">
in the /Configuration/TypoScript/setup.ts File.
The content of libs.ts is:
TSFE-Syntax
lib.sitename = TEXT
lib.sitename.data = GLOBAL:TYPO3_CONF_VARS|SYS|sitename
OR
DB-Syntax
lib.sitename = TEXT
lib.sitename.data = DB:sys_template:1:sitetitle
works both. I read that you use the colon-syntax for DB usage and the pipe-syntax for Global Variables.
To get this to Fluid use this Code:
<f:cObject typoscriptObjectPath="lib.sitename" />
I hope it helps Others who also has this Issue.

RealURL with GET parameters

We have developed a typo3 plug in that searches for trucks. For SEO reasons, we are trying to use the realURL plug in to make the URLs friendlier to use.
On the front page we have several call to actions that link to the search page with certain search parameters. An example is bellow:
/search-results/?tx_fds_searchresults[type_name]=Trailer
This link works as expected. On the results page is a link to the listings page with more details. An example is bellow:
/listing/?tx_fds_listing[id]=119870
This link is not working. tx_fds_listing[id] is not being populated in the arguments passed to the plug in controller.
At first we thought it might be a config issue but again, it isn't present on other pages.
The ID is not a database object and may be a text string instead.
Edit:
I should add that it works fine with RealURL turned off.
We get the id as $id = $this->request->getArgument('id');
Edit 2:
Here is the error message from the logs.
[ALERT] request="28233e225150a" component="TYPO3.CMS.Frontend.ContentObject.Exception.ProductionExceptionHandler": Oops, an error occurred! Code: 201512141630381db91bba - {"exception":"exception 'TYPO3\\CMS\\Extbase\\Mvc\\Exception\\NoSuchArgumentException' with message 'An argument \"id\" does not exist for this request.'
I also tried renaming the variable to name, but that didn't work either.
I have a solution that solves the root cause of the problem, if not the specific issue.
So I had to add additional mapping to the realurl_conf.php file. For example to get the listing id:
$config['domain.com']['postVarSets'][3]['stock'] = array(array('GETvar' => 'tx_fds_listing[id]'));
This makes the effective URL:
/listing/stock/119870
This was the intended usage for the plugin, so this is a good result. I also added configuration for ajax and pdfs. This required modification to the typoscript that was not obvious.
PDF TS:
pdf = PAGE
pdf {
typeNum = 300
10 = USER_INT
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
#vendorName = TYPO3
extensionName = Fds
pluginName = Listing
#controller = FDS
controller = Tx_Fds_Controller_FDSController
#action = listingPdf
switchableControllerActions.FDS.1 = listingPdf
}
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:application/pdf
xhtml_cleaning = 0
admPanel = 0
}
}
PDF RealURL Config:
$config['domain.com']['postVarSets'][3]['pdf'] = array('type' => 'single', 'keyValues' => array ('type' => 300));
PDF effective URL:
/listing/pdf/stock/119870

zend Navigation not right work cause zend router

my url is http://mysite.com/index/bytype/id/5/name/ACTION
when using zend router it'll be rewrite to http://mysite.com/index/bytype/5.ACTION.html
i was config in file router.ini like this:
routes.bytype.type = "Zend_Controller_Router_Route_Regex"
routes.bytype.route = "bytype/(\d+).(.*).html"
routes.bytype.defaults.module = "default"
routes.bytype.defaults.controller = "index"
routes.bytype.defaults.action = "bytype"
routes.bytype.map.1 = "id"
routes.bytype.map.2 = "name"
routes.bytype.map.3 = "page"
routes.bytype.reverse = "bytype/%d.%s.html"
code above have issue when i click button next page , it not jump to next page, cause Parameter page/2 not avalable, zend router was rewrite my url become to http://mysite.com/index/bytype/5.ACTION.html again,
if not rewrite it maybe look like http://mysite.com/index/bytype/id/5/name/ACTION/page/2
so how can i including "page" parameter into url above with zend router.thanks for reading
Try Zend routing on your Bootstrap.php file as an alternative.
Here is a tutorial on how to do that:
http://www.codexperience.co.za/post/hiding-url-parameters-names-using-zend-routers

Zend Framework Rerouting for Friendly SEO URL?

I don't even understand where to start using the documentation and it's instructions. A little dumbfounded.
I have the URL : http://www.site.com/test/view/?aid=155 right now.
I want it to show up as http://www.site.com/test/155 (Using controller "test" and action "view" with parameter aid as 155)
and for future learning experiences, how would I do http://www.site.com/madeupname/155
Where would I start? What file?
What do I put in it?
Please and thank you!!!!!
It's not that hard to do, especially if you use an .ini file for your routes.
Create a routes.ini file inside of your /site/application/configs folder.
For example :
[production]
routes.home.route = /home/
routes.home.defaults.controller = index
routes.home.defaults.action = index
routes.login.route = /login/:username/:password
routes.login.defaults.controller = index
routes.login.defaults.action = login
routes.login.defaults.username = username
routes.login.defaults.password = password
and then bootstrap it
(inside bootstrap.php, add this)
/*
* Initialize router rewriting via .ini file.
*/
protected function _initRewrite()
{
$router = Zend_Controller_Front::getInstance()->getRouter();
$router->addConfig(new Zend_Config_Ini(APPLICATION_PATH. "/configs/routes.ini",
'production'), 'routes');
}
You could then access the login page with www.site.com/login/yourname/yourpass
or get to the home page via www.site.com/home
http://www.devpatch.com/2010/02/load-routes-from-routes-ini-config-file-in-zend-application-bootstrap/
http://framework.zend.com/manual/en/zend.controller.router.html

ModX Evolution: pass variable from url to form text field on page load

I need to pass string from url:
../page.html?code=123456
to a form (eform snippet in modx)
just once is page loaded (link with url and parameter)
Thanks for answer...
My solution:
1. create a new snippet called GetCode
<?php
if( !function_exists('eformGetCode') ) {
function eformGetCode(&$fields,&$templates){
global $modx;
$code = strip_tags($_GET['codeID']);
$templates['tpl']=str_replace('[+display_code+]',$code,$templates['tpl']);
return true; } }
return '';
?>
2. Add eform call (and snippet) on webpage:
[!GetCode!]
[!eForm? ... ... &eFormOnBeforeFormParse=`eformGetCode` !]
3. In eform chunk with form code add line:
<input name="code" id="code" value="[+display_code+]" eform="::1:" type="text"/>
5. Now when you put parametr in url like:
..../page.html?code=123456
this should appear in form.
you would do this exactly like you would in php..
$myVar = $_GET['code'];
If you are having issues, take a peek in the modx error logs...
-sean
Solution by KudyKam is better than official solution in MODX docs, in which they use a database. http://wiki.modxcms.com/index.php/Populate_eform_with_dynamic_data