# |
Jul 13th 2017, 08:16 |
marcusgoede |
i do that because i need a place where the bake shell can find the value with the translate function __(‘value’) and put it into the pot file. is there a better way with just one file to maintain? |
# |
Jul 13th 2017, 08:10 |
hmic |
savants one is faster, this is more readable and flxible, i usually prefer using sprintf for string formatting |
# |
Jul 13th 2017, 08:10 |
jarard01 |
hmic thanks - yes I just tried that and I'm going to use that approach |
# |
Jul 13th 2017, 08:09 |
hmic |
jarard01, you could use printf number formatting too like sprintf('%010d', $int); |
# |
Jul 13th 2017, 08:08 |
jarard01 |
thanks savant that worked |
# |
Jul 13th 2017, 08:08 |
hmic |
marcusgoede: why translate on loading the file? - you will not need all of them in every case for sure. so thats quite a bit of wasted resources. just translate them when you output them - this is how it's usually done and best practise anyways! |
# |
Jul 13th 2017, 08:08 |
jarard01 |
hi neon1025 o/ |
# |
Jul 13th 2017, 08:06 |
neon1024 |
Morning everyone |
# |
Jul 13th 2017, 07:58 |
savant |
http://php.net/manual/en/function.str-pad.php |
# |
Jul 13th 2017, 07:58 |
jarard01 |
so 1 would be come 00000001 |
# |
Jul 13th 2017, 07:58 |
jarard01 |
is there a cake way to add or pad a a number with leading 0's |
# |
Jul 13th 2017, 07:29 |
marcusgoede |
ok thanks |
# |
Jul 13th 2017, 07:29 |
savant |
sure |
# |
Jul 13th 2017, 07:29 |
marcusgoede |
it works in AppController::beforeFilter(), is that good practice? |
# |
Jul 13th 2017, 07:29 |
savant |
you can load it in your AppView |
# |
Jul 13th 2017, 07:29 |
savant |
if its only for templates |
# |
Jul 13th 2017, 07:29 |
savant |
i would load it after you’ve set the language. |
# |
Jul 13th 2017, 07:28 |
marcusgoede |
for example options for select inputs like [‘active’ => __(‘active’)] |
# |
Jul 13th 2017, 07:27 |
savant |
what is in that file? |
# |
Jul 13th 2017, 07:26 |
marcusgoede |
where is a good place to load configuration file with Configure::load() which contain translated values with __()? When I load the config in bootstrap.php the values will be translated to the apps default language, not the current one |
# |
Jul 13th 2017, 07:00 |
spriz |
Okay :slightly_smiling_face: Nice to hear I'm not the only one @savant :tada: |
# |
Jul 13th 2017, 06:19 |
savant |
but I wouldnt write the second way normally at the application later |
# |
Jul 13th 2017, 06:18 |
savant |
or plugins/behaviors that need to be generic |
# |
Jul 13th 2017, 06:18 |
savant |
unless im doing some weird stuff with relations |
# |
Jul 13th 2017, 06:18 |
savant |
i use the former |
# |
Jul 13th 2017, 06:17 |
spriz |
Personally I've used the "old" (first) in own project code and the second only in behaviors, plugins etc. |
# |
Jul 13th 2017, 06:16 |
spriz |
Question regarding syntax for the 3.x orm - which one do you prefer and why? https://gist.github.com/Spriz/645b9e96c1430f141f3d49e225e4ede6 |
# |
Jul 12th 2017, 22:03 |
spencdev |
But generally, and I don't know you're situation so take it for what it's worth, you use the same controller as your model, unless it's an associated table. Or like I said, depending on the situation |
# |
Jul 12th 2017, 22:01 |
spencdev |
You can, I just didn't mean that modifying is the ONLY thing you can do |
# |
Jul 12th 2017, 22:00 |
aaronc |
Gotcha, working now. Why did you explicitly state that I can't modify anything from that Model? Should I just create an edit method for each of those controllers and redirect to that if they choose to edit it? |
# |
Jul 12th 2017, 21:57 |
spencdev |
Not modify, but work with |
# |
Jul 12th 2017, 21:56 |
spencdev |
If you're purposely trying to use ListsController to modify Tests table, you have to load that table in using `$this->loadModel('Tests');` |
# |
Jul 12th 2017, 21:55 |
aaronc |
Yeah the plan was to have a ListsController that can edit the information in several other Tables all in one place. I do have a functional TestsController and TestTable |
# |
Jul 12th 2017, 21:55 |
konstanting |
@chris-andre this looks interesting thanks |
# |
Jul 12th 2017, 21:53 |
spencdev |
Your controller is Lists controller, but you are trying to query using Tests table? |
# |
Jul 12th 2017, 21:50 |
slackebot |
the model? |
# |
Jul 12th 2017, 21:50 |
aaronc |
So I'm still struggling with something that is certainly a basic feature. How do I just query my table manually? I have my controller ``` use Cake\ORM\Query; class ListsController extends AppController { public function index() { $result = $this->Tests->query(); pr($result); } } ``` But it throws an error "Call to a member function query() on boolean. So my Tests variable is a boolean? Does it need to referenced somehow so that it |
# |
Jul 12th 2017, 21:49 |
chris-andre |
@konstanting Have a look https://stackoverflow.com/questions/37658120/linking-two-tables-with-two-composite-foreign-key-relation |
# |
Jul 12th 2017, 21:47 |
konstanting |
Alright then thank you all for your help and input :thumbsup: |
# |
Jul 12th 2017, 21:45 |
konstanting |
yes I think thats the only solution i belongstomany is used |
# |
Jul 12th 2017, 21:44 |
chris-andre |
Right, only I can think of is to have two associations with alias UserA and UserB, then `->contain(['UserA', 'UserB'])` |