Concrete5 hardcode External Form to template - block

I have managed to create an external form using the method: http://www.concrete5.org/community/forums/usage/external-form-email... The form worked when I embedded the block via cms. However, I need to put the form into my template. the following code did not work.
$b = Block::getByName('My Form');
$b->display();
It it probably because my external form did not have a block name. But how could I set its name?

Block names can only be set when the block is placed on a page (which means you're in a catch-22 here and have no way to achieve that).
Instead of attempting to output this block directly, try putting it in a global area in your template instead. You can then tell the global area to not show editing controls or the red dotted outline by disabling them. See http://concrete5tricks.com/blog/dont-hardcode-blocks-use-a-global-area-instead/
btw, you might be interested in this code I have which makes custom contact forms much easier and better than the built-in "external forms" block (in my humble opinion): https://github.com/jordanlev/c5_custom_contact_form

Related

PrintInvoice global variable - BigCommerce

I have the following case:
I'm trying to edit the PrintInvoice.html after downloading it through WebDav. The template was previously edited by another developer, but using the Template Files directly in the Storefront back when the files were visible in the Storefront. When opening the HTML template, the wording that I need to change is inside the global variable %%GLOBAL_ProductsTable%% so I'm not sure how to reach the text content inside. Replacing the global variable with custom HTML is not desirable.
Any suggestions are appreciated!
As others have stated, these global variables are saved within BC's back-end database which you do not have access to.
A workaround my team and I have done to edit the contents of these global variables is to use JavaScript at the bottom of the document that changes the desired text after it is loaded. This seems to be the only way we could find to edit those values.
Global variables like this are provided by the BigCommerce app, it is how the product data is sent through your store to email and can't be modified. To change the product table's appearance, the existing variable would need to be removed and replaced with your custom code.

How to insert custom inline javascript code in php phalcon framework

I want to insert from Controller in the end of some view's code like this
"<"script> setInterval(function(){ alert("Hello"); }, 3000);"<"/script>
How to do this?
There's multiple ways to do this in PhalconPHP. Depending on your needs, you might be able to get away with just:
$js='setInterval(function(){alert("Hello");},3000);';
$this->view->js=$js;
then from the view, you'd do:
<script><?php echo $js; ?></script>
If you need to insert the JavaScript into your top-level index.phtml from a nested view, the way to accomplish this is to first edit your ControllerBase.php and define a new collection:
$this->assets->collection('footer');
Then add a reference to the footer collection from your top-level index.phtml file:
<body>
<?php echo $this->getContent(); ?>
<?php $this->assets->outputJs('footer'); ?>
</body>
You could also use output('footer') instead if you just wanted a dynamic place in the document you can insert HTML of any kind. Note that a collection specializes in managing CSS and JavaScript, hence the outputJS method, but can also handle miscellaneous code for other purposes. There's also outputCSS, outputInlineJs, outputInlineCss, outputInline, and simply output. See:
http://php-phalcon-docs.readthedocs.org/en/latest/api/Phalcon_Assets_Manager.html
Then edit your ControllerBase.php to initialize the asset to an empty collection:
$this->assets->collection('footer');
(if you skip this step, your code will see errors if your top-level index.phtml file tries to output the contents of a non-existent collection if you never write to it, so always initialize it to an empty collection so it exists.)
Finally, from the controller you want to use, you'd do:
$this->assets->collection('footer')->addInlineJs($js);
where $js is your inline JavaScript, excluding the script tags.
You can also work with external JavaScript files by using
->addJs(...). By default it will be relative to your application directory, inserting a / automatically. If you dislike this functionality, you can set the second parameter to false then it will allow you to specify your own leading / or point your resources at another domain.
As far as the assets you can add to a collection, see:
https://docs.phalconphp.com/en/latest/api/Phalcon_Assets_Collection.html
Note that you can also add assets to your collection from your view and the changes would still appear in your top-most index.phtml.
It is also worth noting that you don't need to actually use collections, you can simply use assets without a collection, but I think collections are more powerful in that you get to name them so there's another level of separation in case you need to manage more than one kind of collection of data.
In terms of what you're trying to accomplish, if you're just trying to give the user a message, this is what Phalcon's flash is for, not to be confused with Adobe Flash which is for playing videos. Phalcon's flash is for flashing messages to the user such as error messages, or your form submit successfully kind of messages. See:
https://docs.phalconphp.com/en/latest/reference/flash.html
If you're still confused what flash is, a demo of what it's output is, you can see in the screenshot here: https://docs.phalconphp.com/en/latest/_images/invo-2.png
That is output of ->error(...) and ->notice(...) respectively. The flash component keeps track of a collection of the messages you'd like to show the user. Then once you're ready to display them to the user you'd call:
<?php echo $this->flash->output(); ?> from your view. It is best to make this call from your top-most template or a template which is always included in your top-most template such as your navigation template so you can easily display messages to the user. It is also useful for debugging. I'd suggest using twitter bootstrap for styling the flash output.
Some sample applications which you might find useful:
https://github.com/phalcon/invo
https://github.com/phalcon/vokuro
https://github.com/phalcon/website
https://github.com/phalcon/forum
Further reading:
https://docs.phalconphp.com/en/latest/index.html

Create and use global view in C# WP8 XAML

I was trying to digg something on this topic before, but have no luck. What I'm trying to achieve is pretty simple, but seems to be hard to achieve :-)
I have a WP8 app (C# XAML) and I need to implement global messages (something like toasts) which could be displayed across whole application no matter of current navigation processes. Such toast message(s) should be displayed even while user is navigating between pages. To use the built in toasts is not a way (in case some other solution exists) since I'm possibly in need to have more than one message displayed at the same time (each one is independent of another) and should disappear after specified period of time.
So, my question is. Is there any way how to implement and use some kind of global view instance which sits above all pages and can be called from any page?
All I found until now is the possible ability to use PhoneApplicationFrame, but I would like rather avoid that if possible. I'm still unsure if this is even the way it can be done, but I suppose so. Do you have any alternatives or assurance this is possible and only way to achieve this goal?
Thank you all for your time and answers.
You can have UerControl for the Functionality you are looking for. It is Control that has its own Seprate Xaml and cs file. You can call it from any page into your Project. UserControl provides the base class for defining a new control that encapsulates related existing controls and provides its own logic. You have a XAML file and C# class file for a user control. The class file extends the UserControl class and adds additional behaviours and properties. The XAML file encapsulates the composing controls, the styles, the templates, animations and whatever necessary to form the UI. Since it is a just composition, it is really easy to create. for more Reference you can go here Why and how to create a User Control in Windows Phone
I have ended up rolling my own custom navigation using a single master page. As such any global controls are instantiated once at startup. Navigations are called from my viewmodels and result in usercontrols being removed and added to the visual tree as necessary (using transition animations to give the impression of page navigation) This works but im not sure whether it is best practice and would appreciate some opinions and comments on this. Certainly it solves the problem of global views described.

Extend Page Property with custom controls in Sharepoint

Sharepoint is quite limited when it comes to multi-Lookups because it saves that information in strings. So I changed the Page-Property
"Elements (MultiLookup-> elementIds" on the propertyPage
to an inserted List "PageElements":
"
(SingleLookup)pageId , (singleLookup) elementId"
Because this is quite hard to maintain for my content admins I want that they can enter that information in the page properties like before instead of adding lines into "PageElements"
Therefore I want to add a control that handles that.
I do not need a solution for the task how to achieve that specific function, but a general hint how to add any custom control into a Page property.
I starting point link would be very nice. I just doen't seem to find the right words to feed google with my topic.
Solved this by using a custom field type with that logic. Basicly Described here: http://avinashkt.blogspot.de/2011/07/creating-custom-field-in-sharepoint.html

PrestaShop - Reload CMS page with additional parameters

Situation: I needed to add form with POST method to CMS page. I created custom hook and a module displaying the form successfully. Then I need to react to user input errors eg. when user doesn't enter email address I need to detect it, display the whole page again together with the form and with "errors" in user input clearly stated.
Problem: The problem is to display the WHOLE page again with connected information (eg. about errors etc.). In the module PHP file when I add this kind of code,
return $this->display(__FILE__, 'modulename.tpl');
it (naturally) displays ONLY the form, not the whole CMS page with the form.
In case of this code,
Tools::redirectLink('cms.php?id_cms=7');
I can't get to transfer any information by GET neither POST method.
$_POST['test'] = 1;
Tools::redirectLink('cms.php?id_cms=7&test');
I tried to assign to smarty variables too
$smarty->assign('test', '1');
(I need to use it in .tpl file where the form itself is created) but no way to get it work.
{if isset($test)}...,
{if isset($smarty.post.test)}...,
{if isset($_POST['test'])}... {* neither of these conditionals end up as true *}
Even assigning a GET parameter to url has no impact, because there is link rewriting to some kind of friendly url I guess, no matter I included other argument or not. ([SHOPNAME]/cms.php?id_cms=7&test -> [SHOPNAME]/content/7-cmspage-name)
My question is: is there a way to "redirect" or "reload" current page (or possibly any page generally) in prestashop together with my own data included?
I kind of explained the whole case so I'm open to hear a better overall solution than my (maybe I'm thinking about the case in a wrong way at all). This would be other possible answer.
The simplest method would be to use javascript to validate the form - you can use jQuery to highlight the fields that are in error; providing visual feedback on how the submission failed. In effect you don't allow the user to submit the form (and thus leave the page) until you're happy that the action will succeed. I assume that you will then redirect to another page once a successful submission has been received.
There's lots of articles and how-tos available for using javascript, and indeed jQuery for form validation. If you want to keep the site lean and mean, then you can provide an override for the CMS controller and only enqueue the script for the specific page(s) you want to use form validation on.
If the validation is complex, then you might be best using AJAX and just reloading the form section of your page via a call to your module. Hooks aren't great for this kind of thing, so you might want to consider using an alternative mnethod to inject your code onto the cms page. I've written a few articles on this alternative approach which can be found on my prestashop blog