Breadcrumbs Symfony - symfony1

I'm using an old version of symfony 1.0.11
slot('breadcrumbs');
include_component('page','breadcrumbs',array('past_pages'=>array(
'/module/action/parameter/value'=>'Home ')));
end_slot();
The problem with this code is that parameter and value do not get passed, so If i click on home i get /module/action but the parameters are not being passed. Any suggestions?
Thanks.

There is also a way automatically set the breadcrumbs this is in the breadcrumbs actions:
// Get the full path without get parameters
$fullPath = $request->getPathInfo();
// get the get parameters
$urlParams = $request->getGetParameters();
// set get parameters as string for url
$this->extend = "";
foreach ($urlParams as $key => $urlParam) {
if (empty($this->extend)) {
$this->extend = "?";
}
this->extend .= $key."=".$urlParam;
}
// Get the URL path and Explode by /
$paths = explode('/', $fullPath);;
$this->paths = $paths;
then in the component itself, you can foreach through the paths and if empty just continue. And always give the GET variables with the link if the browser has some.
Home
<?php foreach($paths as $path):
if(empty($path))
continue;
if(empty($fullPath))
$fullPath = "";
$fullPath .= "/".$path.$extend;
$path = str_replace("-", " ", $path);
?>
<?php if(key($paths->getRawValue()) != (count($paths)-1)): ?>
<?php echo ucwords($path); ?>
<?php else: ?>
<span><?php echo ucwords($path); ?></span>
<?php endif; ?>
This way you never have to set your breadcrumbs if you have a correct url structure.

the way i fixed it is
include_component('page','breadcrumbs',array('past_pages'=>array(
'/module/action?parameter=value'=>'Home ')));

Related

(Yii2) Variable not working from post

This is my simple index.php file
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
$this->title = 'Qwert';
?>
<?php $variable=1; //that variable
$f=ActiveForm::begin() ?>
<?php
if($variable==1){
echo Html::submitButton('First Button',['name'=>'b','value'=>1])."<br/>";
}else{
echo Html::submitButton('Second Button',['name'=>'b','value'=>2]);}
if(Yii::$app->request->post('b')==='1' ) {$variable=2;}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;} ?>
<?php ActiveForm::end() ?>
So I want to after click First button it appears Second. Where is my mistake?
You should do the request in your controller and do some ajax in your view.
Keep bellow statements after $variable declaration.
if(Yii::$app->request->post('b')==='1' ) {$variable=2;}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;}
Like
$variable=1;
if(Yii::$app->request->post('b')==='1' ) {$variable=2;}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;}
In my Controller, I have to add return.
if(Yii::$app->request->post('b')==='1' ) {$variable=2; return $this->render('index');}
if(Yii::$app->request->post('b')==='2' ) {$variable=1;return $this->render('index');}

Why is not my url a fully qualified url for paypal?

I have this code
<?php
require '..\..\vendor\autoload.php';
define('SITE_URL','https://www.historietas.mx');
$paypal = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'my_redential',
'my_secret'
)
);
?>
And this code
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(SITE_URL.'\controladores\pagos\pay.php?success=true')
->setCancelUrl(SITE_URL.'\controladores\pagos\pay.php?success=false');
$payment = new Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions([$transaction]);
try{
$payment->create($paypal);
}
catch(PayPal\Exception\PayPalConnectionException $e){
echo $e->getCode();
echo $e->getData();
die($e);
}
echo $approvalUrl = $payment->getApprovalLink();
and I have this error:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'ReturnUrl is not a fully qualified URL'
I don't know what's hapenning I am not using any special character in the url, why is giving me this error? please help, it is very frustating...
remove space from url from your Url that's the issue
include 'vendor/autoload.php';
$checkUrl = 'https://yourdomein.org/user/registration/paypaypal-ch?approval=true&plan=single&email=dghdg#dfgsdh.com&firstname=dshdh0d&lastname=dhdas';
try {
\PayPal\Validation\UrlValidator::validate($checkUrl);
echo "Validated\n";
} catch (InvalidArgumentException $ex) {
echo $ex->getMessage() . "\n";
}
Remove ?success=true
and
Remove ?success=false
from
$redirectUrls->setReturnUrl(SITE_URL.'\controladores\pagos\pay.php?success=true')
->setCancelUrl(SITE_URL.'\controladores\pagos\pay.php?success=false');
and it will wotk for sure.
I had the same problem and it was resolved by using
route('your route name '['parameter 1','parameter2'])
$redirectUrls->setReturnUrl(route('your route name '['parameter 1','parameter2']));

Yii, already define index but `Undefined Index`

I have already properly defined the index to be POST-ed but still it says Undefined Index
Below is my code:
in the _form.php:
<?php echo $form->labelEx($model,'clientPackagedService_id'); ?>
<?php $client = Client::model()->findByPk(1);?>
<?php echo $form->dropDownList($model, 'clientPackagedService_id', CHtml::listData($client->clientPackagedservices(array('condition'=>'client_id='.$client->id.' AND booking_id IS NULL')),'id','packagedServiceInfo'),
array(
'disabled'=>'disabled',
'prompt'=>'Select Packaged Service...',
'ajax' => array( 'type'=>'POST', //request type
'url'=>CController::createUrl('updateMasseuseAndStationListPSID'), //url to call.
//This line-> 'data'=>array('clientPackagedService_id'=>'js:this.value', 'dt'=>'js:$("#Booking_date").val()', 'timeStart'=>'js:$("#Booking_timeStart").val()'),
'dataType'=>'json',
'success'=>'js:function(data) {
//alert(data.masseuse);
var mass="#'.CHtml::activeId($model, 'masseuse_id').'";
$(mass).html(data.masseuse);
$(mass).trigger("chosen:updated");
$(mass+"_chzn").css("width","300px");
$(mass+"_chzn > .chzn-drop").css("width","298px");
var station="#'.CHtml::activeId($model, 'station_id').'";
$(station).html(data.station);
$(station).trigger("chosen:updated");
$(station+"_chzn").css("width","300px");
$(station+"_chzn > .chzn-drop").css("width","298px");
//alert(data.timeEnd);
var timeEnd="#'.CHtml::activeId($model, 'timeEnd').'";
$(timeEnd).val(data.timeEnd);
}',
)
)
); ?>
in the controller.php:
public function actionUpdateMasseuseAndStationListPSID(){
$sid = Booking::getServices($_POST['clientPackagedService_id']);
....(codes to update Masseuse, Station, and TimeEnd.
}
in the model.php
public static function getServices($cpsID){
$psID = Yii::app()->db->createCommand('SELECT packagedService_id FROM client_packagedservice WHERE id='.$cpsID)->queryAll();
$sID = Yii::app()->db->createCommand('SELECT service_id FROM packaged_service WHERE id = '.$psID)->queryAll();
return $sID;
}
As you can see, I have already posted the appropriate name $_POST['clientPackagedService_id'] in the controller.php, but I still get the Error 500: Undefined index: clientPackagedService_id.
Did I do something wrong somewhere? Please advise. Thanks
I think problem is the data your are posting with ajax request. This is your data:
'data'=>array('clientPackagedService_id'=>'js:this.value', 'dt'=>'js:$("#Booking_date").val()', 'timeStart'=>'js:$("#Booking_timeStart").val()'),
Try to change it into this:
'data'=>array('clientPackagedService_id'=>'js:$(this).value', 'dt'=>'js:$("#Booking_date").val()', 'timeStart'=>'js:$("#Booking_timeStart").val()'),
Best way for debugging ajax request is to inspect browser's console. You can see ajax's posted data and realize your problem.

CakePHP requestAction catch error when url not exists

I try to catch error when the requested url does not exist in my application when I use requestAction($url);
with try-catch block, requested wrongs url continue to be loaded;
Please tell me if there is an other solution to test if the url exist, or if the file exist in cakephp dir (my url can be composed of a plugin name).
my actual code:
$url = $appliUrl . $cron['Cron']['plugin'] . '/'. $cron['Cron']['controller'] . '/' . $cron['Cron']['action'];
if (!empty($cron['Cron']['params'])) {
$params = explode(',', $cron['Cron']['params']);
foreach ($params as $param)
$url .= '/' . $param;
}
try{
$output = $this->requestAction($url);
}catch (Exception $e){
$output = "error in the url : ".$url;
}
You can use a variety of methods to accomplish this. In this example, use cURL.
function url_exists($url) {
if (!$fp = curl_init($url)) return false;
return true;
}
Then you can wrap your $output in an if block checking for the url.
if (url_exists($url)) {
$output = $this->requestAction($url);
}
EDIT
Make sure you put the function in a lib or your bootstrap for access. Don't just stick it in your controller like that :)
ANOTHER EDIT
<?php
$ch = curl_init('http://yoururl/');
curl_setopt($ch, CURLOPT_NOBODY, 1);
$c = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HTTP_CODE);

SOAP request in iOS

I have this SOAP request that I use in php to get some information, but I can't seem to figure out how to do this in Xcode, hopefully somebody can point me in the right direction
<?php
$wsdl_url = "https://www.service.com/mySoapService.wsdl";
$client = new SoapClient($wsdl_url);
var_dump($client->__getFunctions());
try {
$userName = 'myUsername';
$password = 'myPassword';
$result = $client->retrieveUsage(new SoapParam(array("UserId" => $userName, "Password" => $password), "RetrieveUsageRequestType"));
print '<pre>';
print_r($result);
print '</pre>';
} catch (Exception $e) {
echo $e->getMessage();
}
?>
Add your WSDL, create stubs and off you go, start using your web-service from iOS apps.
http://sudzc.com/
I hope this is what you are looking for.
Enjoy!
I used http://easywsdl.com to generate classes. Works perfect with my WS

Resources