How to keep track of related table id in other controller? - php

I'm building a module in Prestashop that requires multiple Controllers.
I decided to add them in the Tab, with one visible (the front one), and the others that are related to the first one, in hidden.
When I go to that main admin controller via the menu, it works fine, listing the various elements (renderList) and adding/updating/deleting them also.
Now, when I click on a the view icon, I go to my other admin controller that manage that specific entry (sub list, with it's own form, but related to the parent id).
The problem now, is that I redirect by keeping the correct url, but then, on my sub page, if I click on create for example, I lost the parent_id. And after that, I can't create an entry because it's missing it's parent id.
How can I do to say to this sub controller to keep the id I gave it ?

So far, the only solution I come from is to do like this :
In my sub controller, I should always have id_other_model in the url, so I added this method :
public function initProcess() {
parent::initProcess();
self::$currentIndex .= '&id_other_model='.(int)Tools::getValue('id_other_model');
}
And so far it works well.
If there is a better alternative, I'd appreciate to know it :)

Related

Magento2 Create Dynamic Route For Products

So, i can't find correct, or any solution to this, while it seems like an important topic, basically creating a dynamic route for products or anything, for example, on my main page i get product collection in a list displayed within table, and while clicking on each product, i want to go on it's own page(ndex/products/1 or 2) and i can't figure out how magento2 deals with this, i would love the help, only hint i found it's somehow related to custom route, or cms route don't really know how though

list all products and link each category grid with category box in opencart

I want to load all categories grids on one page and want all products to be available on scroll down. currently I need to click on each category and the page refreshes for each category. This is the site I am working on(ahmad.esy.es). I want this type of functionality upon clicking the category(http://www.just-eat.co.uk/restaurants-hertsplaice-en11/menu#2254). kindly suggest me what changes should I make in view files (product.tpl, category.tpl) or controller files(product.php, category.php). how can I load all the grids of categories in one page
I didn't look at the site you have posted above - if you cannot describe your issue by words or by submitting a code or image it should be improved.
From what I understand you just want an infinite scroll to display all the products you have in your eshop. It is not mentioned whether you want to preserve the default functionality (category tree with products attached to certain categories) or whether you want only this one listing - basically it does not matter - so I will describe in short how to add such new functionality.
The model
you do not need to touch any model - you can reuse the method ModelCatalogProduct::getProducts()
this will give you the possibility to sort or filter the products except you will have to omit the filter_category_id to load all the products
The controller
feel free to create a new controller (e.g. ControllerProductInfinite) or just to reuse one of the already existing - either ControllerProductCategory or ControllerProductProduct
all you need is basically the same as in ControllerProductCategory::index() except adding filter_category_id into a array passed when calling ModelCatalogProduct::getProducts() and a new template for rendering
The template
create a new template that will meet your expectations and infinite scroll requirements
stick to any infinite scroll plugin/implementation you like (may Google be with you)

Joomla: get items modified on setState method

I have a component on two websites.
When an user insert, update or delete an item in the first website, the same action must be performed on the second website. I made that using the postSaveHook() method: when an action is performed in the first site, I connect to the database of the second site and replicate the action.
I need to do the same thing when an user changes the items' state: if he/she unpublishes two items, for example, the items must be unpublished in the second site. I tried to change the setState() method to do that, but inside this method I couldn't get any referente to the items changed.
Does anybody know another solution or how to do that with setState()?
P.S. Sorry about my English.
Finally I found the solution: override the method public function publish(&$pks, $value = 1) of the class JModelAdmin. In this method I have all the primary keys of the items changed. Then I was able to get their states and update the items on the second site.

Where to find a list of pages automatically renderable in Drupal and how it works?

In the pages .tpl.php of my theme i can find several lines like
render($action_links)
displaying whole pages with a single command. Sometime i saw that the render argument is a block from my theme .info, but other times i see arguments i cannot identify that render default pages or elements of drupal.
How it works? And where i can find a list of default displayable pages?
In particular, i needed to display the content of the default drupal page "add content" in one of my pages, and i'm pretty sure i can do it using this render method, but i cannot find the correct argument.
EDIT: I found something like
drupal_render(node_add('NODE_TYPE'));
that seems to allow the display of a node add form, but what i need is the main add content page, containing the list of all the type of nodes that a user can add.
Are you new to Drupal? When I read your post, I'm almost sure that you have missed something with the Drupal's working. The variables you found in render() functions are "calculated" somewhere else in the code (in the modules part for the most).
You cannot find a list of constant variables to display them just like this.
I found this article about these mysterious variables that are rendered and I hope it will help: http://newsignature.com/articles/the-magic-behind-drupals-render-elements
If you just want to display the "add content" form somewhere on your site, just call its path (node/add).
EDIT AFTER CLARIFICATIONS:
First of all, you can set on which page you want the user lands after login. (I don't know why you're still talking about user profile template. Maybe I missed something again.)
But if I did understand what you're trying to achieve, I'll do that:
Create a menu (or simply use the "Navigation" menu that seems to be exactly what you need) with all the actions users can do. And I'll place this menu in the main content region. Do create a menu, go to Administration>Structure>Menus>Add menu. And add links like "node/add/article" or "node/add/news" or "node/add/page" or whatever your content-types are.
Place this menu in the region you want. If you want it to be like the main content of the page, place it in the main container. To do so, go to Administration>Structure>Blocks> Drag and drop your menu in the right region and Save.
Configure this block to appear only on the front page (the first page on user arrives after logged in) if you want so. To do so, in the Blocks administration page, click on "Configure" next to your block and check "show block on specific pages: Only the listed pages" and write down <front>
Create roles and permissions for your different sorts of users. That will automatically show them the links they are allowed to see. To set permissions, go to Administration>People>Permissions and check in the "Node" section which content-type each role can create.
I hope I didn't forget anything. Please tell me if it is clear enough.

block access to certain pages in magento

i have a category in my store, lets call it Program, this category will only have 1 product, lets call it Program product, so, i've developed a module only to show this category and product, the view is diferent from the others categories, so, if i write in my browser the url
myweb.com/index.php/program.html or myweb.com/index.php/program-product.html i can see the custom categories page or the product view page and i don't want that, i want that if someone write this url he will be redirect to another one, how can i do that, if it is posible
thanks
"Do you want the category to show in the category menu but link to your new URL and not show in the old one?"
"yeah, this is exactly what i want, is this possible??"
Try this; Go to the menu Catalog > URL Rewrite Management and find the entry for your category. Crucially it's target path will look something like "catalog/category/view/id/123" ('catalog' is the module, 'category' is the controller, 'view' is the action and 'id/123' is a parameter).
Follow these URL rewrite instructions to delete the above entry then create a replacement. It's only difference will be the target path, use your module's path along with whichever controller, action and parameters are suitable for this case.
By preserving the ID Path of the old rewrite rule you are ensuring it doesn't get overwritten, although I haven't tested this with rebuilding indexes.
Does the category's enabled setting, and the product's visibility setting affect your module's display? If not use those settings to hide them from the catalog but continue using your module as normal.

Categories