Orchard CMS Customer Module - module

My case is that we want to build a customizing Lab Module (show Basic Science Research) which provides a template to show each lab pages in consistent style. This module will also allow each lab's manager(non-developer) to update their own lab pages with some textbox, checkbox, upload file or image, TinyMce plain input elements(not html/css) after they login Orchard (or Developer directly provides them some links to update page infos without login, best not in Admin Dashboard). Each lab page will show Research, Project, Members, Publication, News Sections in front-end. My current plan is creating ResearchLab type (ResearchLabPart/ResearchLabRecord includes lab title, research_topic, research_image, research_protocol etc), Project type (ProjectPart/ProjectRecord includes title, start_date, foreign key researchLab_Id etc), Member type(MemberPart/MemberRecord include name, title, Linkedin links, foreign key researchLab_Id etc), Publication Type(Member/MemberRecord include name, title, Linkedin links, foreign key researchLab_Id and project_Id etc) etc. The foreign key is that once a researchlab id is chosen and based on this value, corresponding project, publication and news for specific lab could be queried as well right away. When lab manager updates the Researchlab part page, he/she wants to upload some research_image or protocol pdf, doc files. For ResearchLabPart (having lab_title, research_topic, research_image, research_protocol properties etc) and I could easily attach ImageField (assuming name ResearchLabImage) as OfType("MediaPickerField") or fileField(some external module) into ResearchLabPart in Migration.cs after enabling these two external modules. In the ResearchLabController of my custom module, Edit Action will view link to a return model=_contentManager.BuildEditor(ResearchLab) which will go to EditorTemplates--Parts--ResearchLab.cshtml. I want to assign the url (or file/image's name values, using ((dynamic)Model.ContentItem).ResearchLab.ResearchLabImage ) into research_image, research_protocol properties of ResearchLabPart. It looks like I need to implement assigning values in Eitor method of LabMemberDriver, not sure? My target is to let file or image fields to save files and images in some folders under my module directory and save the files or images's name or url path into photo, cv properties of LabMemberPart. Am I going to right direction? How to connect and exchange image/file fields to the properties of ResearchLab part in source code part? Any thoughts or comments are welcome. Thanks.

Related

How to create content types that are not list in Sanity Studio?

I know how to create a content type in Sanity Studio for lists. For example, blog posts, customers, orders, payments, etc.
But now I want to use a Sanity project to provide content data for my home page.
On my home page, I have a Hero section, that is not a list.
It contains a title, a description, and a CTA that has text and a link.
How can I define the schema of this section, in my Sanity Studio?

directus: regenerate thumbnails after having manually inserted into directus_files table

I manually inserted images into my collection table and into directus_files table with matching uuid and filename.
When I click on an item of my collection I can see the image however the thumbnails are broken:
I can see that if I manually upload an image through directus admin interface two thumbnails are created in the local folder with an uuid and a double underscore and a random hash I cannot figure out how is made.
Is there any way to regenerate the thumbnails?
Ok found out, you basically have to harness the REST API to regenerate the thumbnails otherwise Directus is not "smart" enough to regenerate them when you open an item from the collection or fallback to the original image.
The thumbnail also uses a strange hash in the filename derived from the creation time and user so you won't find the name explicitly in any table of the database.
The REST API has to be called as follows:
http://localhost:8055/assets/c1982e98-5b6d-4327-807a-2561002029d7?access_token=mytoken&width=60&height=60&quality=80
the access token is created from the user administration panel, the guid is the one in the database associated with the image.
Notice the width and height must be specified in the database table associated with the image otherwise the REST API will return a warning.

Piranha CMS customisation

A few questions on customisation with Piranha CMS.
Is there a way to create additional custom site-wide items similar to those from the site helper? http://piranhacms.org/docs/api-reference/site-helper
e.g. to be able to set a phone number used throughout the site but still editable in the settings section of the manager.
Is is possible to create additional custom items for a page, e.g. page subtitle, and for those to appear in the Information section of page editing? Creating a region for say a page subtitle seems overkill.
Is it possible to create a custom page type with a region that is a collection of HtmlRegions or similar? e.g. for the purpose of managing a set of FAQs or similar enumerated content?
Is is possible to define custom settings properties for a page type?
Yes, you can add regions to your site in the same way as with page types under Settings > Sites. You then add content for them under Content > Pages > Edit Site.
You can add simple text properties on the page type. They will be shown as single line text inputs under Properties when editing the page.
No native support, however the region body can be anything that can be serialized to JSON so you have to handle this in the edit view for your region.
There is no support for injecting fields into the page settings, however if it's important you can override the whole edit view for pages and do anything you like by placing a copy of the view in the manager area in your local project. You can find the views in the github repo in the 2.2.5 branch.
Regards
Håkan

New module for personal collection/receive with possibility to choose shop (pickup to store)

I want to add possibility for clients to receive orders personally in one of our shops. I tried to find some module which gives possibility to select in which shop they want to receive order but I haven't found anything for free. Because of that I want to create new module for it. What's more I'm totally new in prestashop and I don't know where to start or how to create this module. I spend two-three days reading how to do it and these are my assumptions:
New carrier module can be created by extending CarrierModule class.
I read some articles / documentation about hooks.
I have created my first carrier module by editing module attached in this article http://www.prestashop.com/blog/en/carrier_modules_functions_creation_and_configuration/.
What I achieved is that I installed module and used hook 'BeforeCarrier' to add some layout to page after selecting my carrier.
This is how my carrier should work:
It should be a part of carrier list so customer is able to select it.
If carrier is not selected nothing hapens. If carrier is selected by customer then button 'Choose shop' should be shown.
After pressing button 'Choose shop' new window should be show with addresses of our shops (instead of new window it may be placed somewhere in current page).
Window with shop adresses will contain list of addresses with radiobuttons and button to confirm selection.
After confirmation of selection window will be closed and address should be shown as a part of carreir.
E-mail with confirmation will contain information in which shop customer can collect order.
Suppose that addresses will be hardcoded in php code.
These are my questions:
I created new carrier module so I assume it works correctly (as described here http://www.prestashop.com/blog/en/carrier_modules_functions_creation_and_configuration/).
How to add new button 'Choose shop' near selected carrier?
Can I use hooks to add 'Choose shop' button?
Where should I remember choosen shop address? Has 'Carrier' class place for it?
How to add shop address to e-mails? Should I edit layouts? Does e-mail layout contain place for it or do I need to add new 'placeholder' for it?
How to show chosen address on admin side?
To describe my problem more detail I have created few scenario (see attachment).
I will be greatful for any help.
I've posted the same question on prestashop forum.
These example are usually old and poorly written. They lack structure. But for your purpose I suppose they're ok.
Use hookDisplayCarrierList($args). Check $args to see which carrier has been selected, then return <select> element which you
shop addresses. This hook is triggered every time a user selects a carrier and is return via Ajax. Therefore, you may not use ajax here.
You should include you javascript in a file. Use hookDisplayHeader to detect when to insert this file into your page:
public function hookDisplayHeader(){
$propExists = property_exists($this->context->controller, 'php_self');
if($propExists){
$controllerName = $this->context->controller->php_self;
if(in_array($controllerName, array('order', 'order-opc'))){
// $this->context->controller->addJS($this->_path.'js/customcarrier.js');
This Javascript file should check whether a valid shop has been selected before going to the next step;
Because your Js code is in a file and the hookDisplayCarrierList cannot contain any JavaScript (because it returns Ajax),
you should also make use of hookDisplayBeforeCarrier. Here you could insert you custom carrier ID - this way you'd know
when to check for errors with your JS file.
Same question as #2.
The correct way to save the information would be to add a model. CustomCarrierSelectedAddress - or something like it.
It would have these columns: id_cart, id_shop_address;
The way you implement shop addresses is up to you. You may define them as constants or even make a new model for them.
Models arent that hard to create, you just need to declare class properties, static variable $definition that's it.
You may add you own methods. You should also add createTable()/dropTable() methods for convenience.
This is more complicated. You could:
Send your own email about selected shop address.
Search the controller method which send the email you wish to change.
Then you should override that method by copying the file to your module, delete all the other methods and
rename the class definition inside -> class AdminAddressesController extends AdminAddressesControllerCore
There should be an array of email placeholders and their values, which the controllers assigns.
for example '{order_id}'. You should add your email variable to array {chosen_shop_info} and assign whole
paragraph of text to it. Then you may use it in the actual email template which you can edit in BO.
This is more or less the only way I know to edit the existing templates, because you can't do conditional statements inside email templates.
To add chosen address to order page in BO, you should use another hook - hookDisplayAdminOrder.
here you can add your own block to be display in order summary.
To find out which hooks are available, go to Hook.php and look for method exec(). Add this line error_log($hook_name).
When you perform a specific action, executed hooks will be logged and you will see what kind of hook you need.

Multi-lingual for Product Description

In a Product page of the front-end Demo Store, under the Description and Additional Information tabs are still in English even if I have changed the site language to Japanese. The same goes to the name of the Categories (Audio & MP3, Computers & Tablets, Cameras, etc).
Can I provide my own translation of Japanese for these areas?
Translating Additional Information:
Open catalog and add Japanese language to it (catalog guide);
Open concrete product, navigate to Properties, change displayed properties language to
Japanese (by clicking language filter in top left corner);
Fill in the properties and save;
In order to see the changes in website, rebuild the search index (settings guide).
The Description (Editorial Review) doesn't support localization at the moment. There are several workarounds but they all include programming.
Yes, you can provide your own content. Some of the text simply wasn't translated to the Japanese. You can translate everything from category names to labels using Commerce Manager console. For categories, simply go to the category edit page and set a translating for display name property to Japanese.