Ok so it used to be in application/controller/classes/ where my controllers are.
Now i would like to have better structure, so i moved my user controllers to the user/ directory.
So this:
Route::set('user', 'user(/<action>)')
->defaults(array(
'controller' => 'user',
'action' => 'index',
));
Got changed to:
Route::set('user', 'user(/<action>)')
->defaults(array(
'directory' => 'user',
'controller' => 'user',
'action' => 'index',
));
Now i receive error, e.g user/login not found.
The controller for the above example, is in application/controller/classes/user/user.php.
I tried to remove the bottom default route just in case it was going through that, but no it still doesnt not work.
Have you changed name of your controller class? The directory name must be in the controllers name, in your case it should be Controller_User_User.
Related
I am trying to create api where different sites will use our api which will generate a token and they will use that token to redirect the user
I am using this code
$checkout_session = \Stripe\Checkout\Session::create([
'customer_email' => $customer_email,
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => 'dkk',
'unit_amount' => $course_price,
'product_data' => [
'name' => $course_title,
'images' => [$course_image],
],
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => $success_url,
'cancel_url' => $cancel_url,
]);
I want to make the back button dynamic is it possible?
Not possible. The Checkout Session is created using your account's public key. So naturally, the "back" button on the Checkout page will show your domain.
What you can change however, is the text of the payment button (although not as flexible as you'd wish): https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-submit_type
Changing the name for a single account is not possible as it was in the old stripe version. But in the Stripe session checkout, if you are having multiple connected accounts, you can change the Public business name (if you have access, otherwise ask account owner) to whatever the business wants from the stripe portal https://dashboard.stripe.com/settings/account.
I developed an extension which allows creation of new records.
In List module, under the records list, there is the Search form.
It works with fe users for example, but not with my custom records.
Is there any special configuration that I have to add in my tca to make this form work with my custom records?
EDIT: This seems to be happening after updating to TYPO3 4.6. In the previous version, 4.3.3, it works.
Thanks.
Edit ext_tables.php file in typo3conf/ext/yourext directory, find your table, and add to its ctrl section searchFields property as comma separated list of fields to search in:
$TCA['tx_yourext_table'] = array(
'ctrl' => array(
'title' => 'Title of your table',
'label' => 'title',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
// etc...
'searchFields' => 'title, other_field, yet_other_field',
),
);
Don't forget to clear all caches after that, works at 4.6.3
There's official information when and why it was changed
Is it possible to create a validation rule in Kohana 3 that will validate the has_many through relationship?
Using the example on the guide page, a blog post can have many categories through the categories_posts table. Is there a validation rule that can be setup in the Post model to verify at least one category was added?
I tried the following:
public function rules()
{
return array(
'categories' => array(
array(array($this, 'has'), array('categories'))
)
);
}
because I see that the ORM::has function will return true/false. But I think because 'categories' is a relationship, and not a field, the rule I wrote never gets checked.
Any ideas?
You must save Post before adding has_many relations. You can check Post for categories after saving, and mark it as draft if they were not set.
Woo, good idea.
Focus in MVC design pattern. I think that's C business not the M.
if ($post->categories->find_all())
{
//blablabla
}
Since categories is external to the posts table, you'll want to use external validation. Create a function called Model_Post::rule_has_valid_categories($submitted_categories, $post) that returns a boolean denoting whether or not the submitted categories are valid for this post.
Then, create the extra rule just before you try to save the post:
$extra_rules = Validation::factory(array('categories' => $submitted_categories))
->rule(
'categories',
'Model_Post::rule_has_valid_categories',
array(':value', ':model')
);
try
{
$post->save($extra_rules);
}
catch (ORM_Validation_Exception $e)
{
// if categories rule failed, array will contain _external[categories] field
print_r($e->errors('models'));
}
You store the message in /application/messages/models/post/_external.php:
return array(
'categories' => array(
'Model_Post::rule_has_valid_categories' => 'Invalid categories'
),
);
I have multiple controllers in my Kohana 3.2 project where the routes where initially:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'user',
'action' => 'index',
));
It was working fine for all my new controllers (when I added a new file and went to: domain/controller it worked like a charm.
Now for a specific controller called parents I had to add new lines in my bootstrap:
Route::set('parents', '(<controller>(/<action>))')
->defaults(array(
'controller' => 'parents',
'action' => 'index',
));
Route::set('parent', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'parent',
'action' => 'index',
));
I was trying to access both: /parents/ and /parent/index/id and both generated an error when not having the Route::set in place.
Without those lines, I always got errors like:
unable to find a route to match the uri
OR
The requested route does not exist
How am I supposed to do it? For every controller that I add do I need to define it in my bootstrap?
Actually you'd be covered with just the default route in your case.
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'user',
'action' => 'index',
));
First, Kohana tries to match against your regex pattern [((/(/)))]. This will match the urls: users, users/delete, users/delete/1, parents, parents/view, parents/view/2, etc.
If Kohana is unable to find the action, it will default to index based on your defaults array rule. If Kohana is unable to find a controller (which essentially means nothing passed), then it will use controller. In the last case, it would also default the action since we can't pass an action without passing a controller in our regex (see the parenthesis requires a controller first then action then id).
So the following examples will route through this default pattern:
URL: /users
Controller: users
Action: index (picked default)
URL: /users/kill/1
Controller: users
Action: kill
Id: 1
URL: /parents
Controller: parents
Action: index (picked default)
URL: /parent/view
Controller: parent
Action: view
Best practice is to keep this route as the last route applied (essentially the default and catch all) and if you have urls that don't match the pattern in the default, add them.
I'd better use one route for all this:
Route::set('p', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'action' => 'index',
));
If you call /parents/father - you get to parents controller, if you call /parent/father you get to parent
I have an SMF forum currently running on SMF 2.0RC4 and the moderators can change their post count. This is not a big problem as it's only available for the mods, but still I would like to know where I can change this. I found some settings in permissions settings, but when disabled, they could not change anything in the profile.
You can hack your way out of it.
In ./Sources/Profile-Modify.php on line 568
'posts' => array(
'type' => 'int',
'label' => $txt['profile_posts'],
'log_change' => true,
'size' => 7,
'permission' => 'moderate_forum'
Change 'permission' => 'moderate_forum' to 'permission' => 'admin_forum'.
Then only admins can edit the post count.