How to make a sitemap using zend framework 1 [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to create a sitemap for a website that is coded in zf1 but I don't know anything about this.
I've read on google that I need a controller, a view and routes for it but what I found is for zf2 and doesn't works.
Did someone makes this ?

You should use the Zend_Navigation class and navigation sitemap view helper inside a Controller Action, as follows:
public function sitemapAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(true);
$items = array(
array(
'title' => 'Title 1',
'label' => 'Label 1',
'uri' => 'https://www.example.com/page1',
'order' => 1,
'type' => 'uri',
'changefreq' => 'weekly',
),
array(
'title' => 'Title 2',
'label' => 'Label 2',
'uri' => 'https://www.example.com/page2',
'order' => 2,
'type' => 'uri',
'changefreq' => 'weekly',
)
);
$nav = new Zend_Navigation($items);
$sitemapOutput = $this->view->navigation($nav)->sitemap();
$this->_response->setHeader('Content-Type', 'text/xml; charset=utf-8')->setBody($sitemapOutput);
}

Related

How to change Start and Submission not to be required [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 days ago.
Improve this question
I don't know which one I should change
'client_name' => 'required|max:250',
'start_date' => 'required|max:250',
'status' => 'required|max:250',
'service_id' => 'required',
'content' => 'required',
'serial_number' => 'required',
'language_id' => 'required',
$portfolio->start_date = $request->start_date;
$portfolio->submission_date = $request->submission_date;
I haven't tried anything. I just want the start and submission dates fields to not be required

Calendar in Zend Framework dynamique [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 days ago.
Improve this question
I looking to create two custom calenders with Zend Framework, i am hoping the end date (if input is not empty) is bigg than begin date.
If user set end date small than begin date i want to display error message : "can make a date bigg than begin date".
[
'type' => 'calendar',
'name' => 'begindate',
'options' => [
'label' => 'begin date">*</span>',
'label_options' => ['disable_html_escape' => true],
],
'attributes' => [
'data-scvalidators' => 'Required',
'data-required-msg' => 'make the begin date.',
'data-sc-submit' => '.sumbit',
],
],
[
'type' => 'calendar',
'name' => 'enddate',
'options' => [
'label' => 'END DATE',
],
],
The exemple image

lookup function in PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Is there any built in function to enable the lookup function in PHP like the excel one? I thought the array_search would be the closest one, but it won't work if the mixed needle(value) has more than one values. To illustrate, the lookup I try to perform is:
function lookup($datatype){
$array = array(
'BINARY' => 'RAW',
'REAL' => 'FLOAT',
'INTEGER' => 'NUMBER',
'DATETIME' => 'DATE',
'VARCHAR' => 'VARCHAR2',
'DATETIME' => 'TIMESTAMP',
'VARBINARY' => 'BFILE',
'INT' => 'NUMERIC'
);
$key = array_search($datatype, $array);
return $key;
}
If the lookup is for the 'RAW', array_search will return 'BINARY', but when the lookup is 'DATE', it won't return anything.
Any thoughts would be much appreciated.
the $array has the same key 'DATETIME' twice ,second one will overrite the first, so $array don't have the 'DATE' key
You can't have the same key twice in your array! You can instead of 'DATETIME' to 'DATETIME_test'
function lookup($datatype){
$array = array(
'BINARY' => 'RAW',
'REAL' => 'FLOAT',
'INTEGER' => 'NUMBER',
'DATETIME_test' => 'DATE',
'VARCHAR' => 'VARCHAR2',
'DATETIME' => 'TIMESTAMP',
'VARBINARY' => 'BFILE',
'INT' => 'NUMERIC',
);
$key = array_search($datatype, $array);
return $key;
}
var_dump(lookup('DATE'));
As you mentioned your array, there is duplicate key of "DATETIME", so it will overwrite by last value. and your array would be as follow.
$array = array(
'BINARY' => 'RAW',
'REAL' => 'FLOAT',
'INTEGER' => 'NUMBER',
'VARCHAR' => 'VARCHAR2',
'DATETIME' => 'TIMESTAMP',
'VARBINARY' => 'BFILE',
'INT' => 'NUMERIC'
);
so whenever you are trying to filter out or willing to get, only one key is available.
Better to write down with different key. and then try to array_search for key.

PHP Multidimensional array with foreach [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Trying to build the multidimensional array with a foreach using record from a db...
$servDetails = array(
// CSS Servers
'css' => array(
'server1' => array(
'id' => 'id1',
'type' => 'css',
'host' => 'ip:port'
),
'server2' => array(
'id' => 'id2',
'type' => 'css',
'host' => 'ip:port'
)
)
);
What's the best way of doing this?
Assuming you have executed and have populated an associative array:
// create your containing array
$servDetails = array('css' => array());
// iterate over the results
foreach ($results as $result) {
$servDetails['css'][$result['server_name']] = array(
'id' => $result['server_id'],
'type' => 'css',
'host' => $result['server_ip'] . ':' . $result['server_port']
);
}
I'm not sure where the 'css' portion comes from in your sample, so you may have to adjust this to make it dynamic (if it is in fact dynamic).
You could also build this array structure directly when pulling the results from the db:
if ($results = $mysqli->query($query)) {
while ($result = $results->fetch_assoc()) {
$servDetails['css'][$result['server_name']] = array(
'id' => $result['server_id'],
'type' => 'css',
'host' => $result['server_ip'] . ':' . $result['server_port']
);
}

associated models not loaded in code generated by cake php console [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I used the cakephp console to generate some CRUD operations. The generated code was buggy as the model of an associated model was not loaded by default in the controller.
For instance:
$programs = $this->Chantier->Program->find('list');
would not work, but:
$this->loadModel('Program');
$programs = $this->Program->find('list');
would.
Here is the code of the associations:
/**
* belongsTo associations
*
* #var array
*/
public $belongsTo = array(
'Programs' => array(
'className' => 'Programs',
'foreignKey' => 'Programs_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Etats' => array(
'className' => 'Etats',
'foreignKey' => 'Etats_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Types' => array(
'className' => 'Types',
'foreignKey' => 'Types_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'ChampsLibres' => array(
'className' => 'ChampsLibres',
'foreignKey' => 'Champs_libres_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);
Take a close look to your code:
public $belongsTo = array(
'Programs' => array(
'className' => 'Programs',
'foreignKey' => 'Programs_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
Both the alias for the association and classname are in plural, while this is possible and fine, it goes against CakePHP conventions. You are trying this:
$programs = $this->Chantier->Program->find('list');
But note that you wrote Program in singular and not in plural as declared in your associations. I would suggest to re-bake your code to follow convention to avoid future headaches and confusion.

Categories