directory separator in cakephp disables my CSS - css

is what I get, everytime I use this,
$certpath = APP."Plugin".DS."PaypalIpn".DS."Controller".DS."Certificates".DS;
in my code, it ruins my css. Well, not necessarily ruins but my page is as if not using any css for its alignment or other stuff.
i need that DS since i have to call a file in that directory
$encryption['cert_file'] = $certpath.$encryption['cert_file'];
I tried this:
$encryption['key_file'] = $certpath.DS.$encryption['key_file'];
$encryption['cert_file'] = $certpath.DS.$encryption['cert_file'];
$encryption['paypal_cert_file'] = $certpath.DS.$encryption['paypal_cert_file'];
Still no luck. The first two lines work that way, but the third one doesn't.
And I tried googling with these keywords:
directory separator in cakephp ruins my css
uses of directory separator in cakephp
calling files using directory separator in cakephp
but none of it helped me.
DS is just a directory separator right? What could possibly be wrong?
.......... edited part
well this is another issue, I found the culprit from my previous issue but please do explain so how it is related to my problem. this is my PaypalHelper.php
<?php
$importConfig = array(
'type' => 'File',
'name' => 'PaypalIpn.ppcrypto',
//'file' => CONFIGS .'paypal_ipn_config.php'
'file' => APP."Plugin".DS."paypal_ipn".DS."libs".DS."ppcrypto.php"
);
//... other codes
//..other functions
function button($title, $options = array(), $buttonOptions = array()) {
//..other codes
$certpath = APP."Plugin".DS."PaypalIpn".DS."Controller".DS."Certificates".DS;
//..other codes
}
?>
see this code?
$importConfig = array(
'type' => 'File',
'name' => 'PaypalIpn.ppcrypto',
//'file' => CONFIGS .'paypal_ipn_config.php'
'file' => APP."Plugin".DS."paypal_ipn".DS."libs".DS."ppcrypto.php"
);
and this?
$certpath = APP."Plugin".DS."PaypalIpn".DS."Controller".DS."Certificates".DS;
$encryption['paypal_cert_file'] = $certpath.$encryption['paypal_cert_file'];
the $importConfig..it was wrong coz it should be
$importConfig = array(
'type' => 'File',
'name' => 'PaypalIpn.ppcrypto',
//'file' => CONFIGS .'paypal_ipn_config.php'
'file' => APP."Plugin".DS."PaypalIpn".DS."libs".DS."ppcrypto.php"
);
..but when i tried to correct it, $encryption['paypal_cert_file'] worked fine. It doesn't ruins/(disables??) my css
i put this as an answer first but i believe there are still questions raising in my head..

I am almost certain whatever is or was wrong is either a fatal error or some kind of other error output messing up your HTML output.
Sometimes even with debugging enabled the error isn't visible on the screen and you must check the HTML source, especially if the error occurs in the <head> section of the HTML, inside Javascript or before the closing > of a tag. I would suggest that when you fixed the error, it fixed your problem.
I would double check that you have debugging enabled. See CakePHP Core Configuration from the cake documentation.
If you have fixed the problem but still want to know what caused it, if possible, undo your changes and check what I have mentioned above. Other than that I don't see anything immediately obvious in your code which could have cause the problem.

Related

GravityForms - List Field with multiple DropDown on entries column - fatal syntax error using recommended snippet

I am trying to use this code (with different choices for the second dropdown) but keep getting a fatal error on line 1: syntax error, unexpected 'set_column2’' (T_STRING), expecting ')'
This my my code:
add_filter( 'gform_column_input_6_22_4’, 'set_column2’, 10, 5 );
function set_column2( $input_info, $field, $column, $value, $form_id ) {
return array( 'type' => 'select', 'choices' => 'One, Two' );
}
I understand I'm missing a ' (I think?) but I can't understand where? Everything seems complete.
It's the closing ` on set_column2, it's the wrong type of ' ! Be careful when copying and pasting code directly, as sometimes the formatting might be wrong. Most IDEs can colour code your code and that can help highlight when these errors occur (in actual fact Stack Overflow's colour coding code snippets told me immediately where the problem was)

Populate Image & Image List Fields with Bolt CMS Programatically

I am attempting to create entries programaticaly in Bolt 4. I have managed to create basic text entries fine which covers the majority of fields I need to fill in however unsure how to go about image and image list types.
$content->setFieldValue('name', 'Test Name');
Works fine for most fields as stated but images field types looks like below in database and am unsure what the "Bolt / Symfony / Doctrine" way of generating below is:
{"media":11,"filename":"entity\/year\/month\/image.jpg","alt":"","0":""}
Which looks like some JSON formatted to contain a media ID, file path and an alt attribute. I'm guessing image lists are similar but with multiple of above but hoping there is a function I can use to generate this output as unsure how I would grab media ID etc.
Am assuming I may need to upload a file temporarily from an external URL and provide this to some function however cannot find any examples. Any help would be much appreciated.
Not quite sure on this but will answer anyway as it works and may help someone else, but would be good to clear some of the bits up.
Example of an Image:
//not sure what goes in media here but blank seemed to not work here but a 7 did as looked at example in database however worried this is wrong and should be an Id
$image = array('media' => '7', 'filename' => $filename, 'alt' => $image['Alt'], '0' => '');
$imageJSON = json_encode($image);
$content->setFieldValue('image', $image);
Example of an Image List:
$images = array();
foreach ($images as $image) {
$ImageId = $image['id'];
//images may be already on system but I had to download them here
if ($fileName = $this->downloadImage($propertyFile->{'url'}->__toString(), $ImageId)) {
//not sure what goes in media here but seemed to work blank for imagelist type and unsure what the 0 is on the end either
$image[] = array('media' => '', 'filename' => $filename, 'alt' => $image['Alt'], '0' => ''); }
}
$imageJSON = json_encode($image);
$content->setFieldValue('gallery', $image);

Symfony - render twig code in controller

I need to build a customizer for my customers. They will be able to choose between multiple templates for their subdomain.
In order to do that, I took the following path :
Store templates in the DB with twig tags for the user's data
When needing to display a preview of a template, I would get it from the DB
Then I would render it in the controller and send the resulting HTML as a variable to the main template
I'm not succeeding into rendering in the controller. I tried several things, but the closest I got is this :
$loader = new Twig_Loader_Array(array(
'code.html' => $site->getTheme()->getCode(),
));
$twig = new Twig_Environment($loader);
$code = $twig->render('code.html', array( "test" => "CUSTOM DATA" ));
But I miss a use statement :
Attempted to load class "Twig_Loader_Array" from namespace "AppBundle\Controller". Did you forget a "use" statement for another namespace?
I'm not sure if it's the right path though.
So, if it is, please help me find out what use statement to use. More generally, how do you find what use statement should be used ?
If it's not the right strategy according to you, please feel free to explain me how dumb my idea was :)
[EDIT] So thanks to #DarkBee I found this solution that works, but I'm not sure whether I should do this or not :
use Twig\Loader\ArrayLoader;
use Twig\Environment;
...
$loader = new ArrayLoader(array(
'code.html' => $site->getTheme()->getCode(),
));
$twig = new Environment($loader);
$code = $twig->render('code.html', array( "test" => "CUSTOM DATA" ));
So if it's ok, great. If it's wrong (or again, if I'm wrong in the strategy choices), please tell me why and what would be better.

Laravel 5.2 PHPunit form submit create new record

I have the following code.
Login user and validation works, returns true.
The problem is seePageIs, it returns an error. But after posting the respons has to go to company lister page. So if i change the ->seePageIs('admin/company') to ->seePageIs('admin/company/create') it works.
What's wrong?
Error:
Failed asserting that two strings are equal.
Expected :'http://localhost/admin/company'
Actual :'http://localhost/admin/company/create'
Test:
public function testExample()
{
$this->be(User::find(4));
$rules = array(
'companyname' => 'required',
'email' => 'required|email',
);
$data = [
'companyname' => 'aa',
'email' => 'aaaa#aa.nl']
;
$v = $this->app['validator']->make( $data, $rules);
$this->visit('admin/company/create')
->press('Create')
->assertTrue($v->passes())
->seePageIs('admin/company');
}
I'm not sure I understand your code very well and your question, but maybe it is this line:
$this->visit('admin/company/create')
->press('Create')
->assertTrue($v->passes())
->seePageIs('admin/company/create');
I just changed the line seePageIs() to add create at the end. Maybe that is the problem?
Try it.
If not, can you show your code for assertEquals(...)... Thanks!
EDIT #2
Hi there Bas; based on your comments and what I think you are trying to do:
If after creating the company, then you want to check it, then you probably need to do this instead:
$this->visit('admin/company')
->seePageIs('admin/company');
Which just goes to the company page an verifies that is the correct page.

WordPress function get_the_terms() returns 'Invalid taxonomy' error [duplicate]

On my local machine it works fine, but on the live server, when I run
get_terms('taxonomy' => 'any_taxonomy');
it returns a list of terms, but if I add any parameter to it like:
get_terms('taxonomy' => 'any_taxonomy','hide_empty' => false);
Then it returns "invalid taxonomy". The issue is not that the taxonomy is not registerd get_taxonomies() before it, it shows that all the taxonomies are registered. If I do this:
get_terms('taxonomy' => 'category','hide_empty' => false);
The same problem is there, so its not just custom taxonomies.
Any idea what could be causing this issue?
Can anyone suggest a way to diagnose this?
i'd say you are running different versions of wordpress, 4.5 changed the functionality of get_terms()
get_terms( array('taxonomy' => 'any_taxonomy','hide_empty' => false) );
Should work, but i also think if you are calling get_terms() before registering your taxonomy is going to cause issues.

Resources