Customizable form doesn't show - silverstripe

I've made customizable form but it doesn't show on the page. It is my first time using silverstripe and I couldn't understand from the documentation which is even the entry file. Don't really know what should I write as here because I don't have code at all. Can only show the form as image.

You'll need to put a $Form tag in your template (probably Page.ss) where you want the form to appear.

Related

Embedding the view of a url inside the header of another view

Currently, I have a dynamically created custom pie chart located at mywebsite.com/customchart that is created through a module I made using Highcharts.
I have view, that is listed in the views module shown in mywebsite.com/admin/structure/views/view/ which I would like to embed the custom chart into but I cannot find it through Add Header>Global: View area.
How exactly would one be able to achieve this? Programatically? How?
You can do it programmatically.
First you have to find out what template file is used for rendering the header. Easiest way: go editing your view, select proper display and then unfold "Advanced" options block on the right column and click "Theme: information". Here you can see what templates files are used (assuming you are using Drupal 7). The used ones are in bold. You can collect actual template code there so you don't have to find template file at all if you want to override it. And you can see file naming suggestions, so there you have everything you need to override template file.
If your theme is not overriding standard templates then you should do that - it's not good idea to change directly templates provided by Views module.
So, the first part would be finding out where would you like to embed the view, at what template and at what position. Second part is using function views_embed_view() for doing that:
https://api.drupal.org/api/views/views.module/function/views_embed_view/7.x-3.x
As you can see there, first parameter is machine name of the view, second of display and then you can pass parameters if your view accepts them. So call that function from proper place and you'll have your view embedded.
Also, there is display type "embed" which you can use for embedding views like this. It will provide those "edit view" links when you hover your view content while logged in as admin...

How to show two views on one page in drupal

How can I show multi views on single page in Drupal?
I need to show two results, (maybe you can think 2 tables, but actually 2 views) on one page.
Anyone please help me.
You can use the panels module. That will allow you to put views in different types of layout on a page. And take arguments as required.
You can do it by creating a page with your first view. For the second view you have to create a block and add it to that page.
btw: please use https://drupal.stackexchange.com/ for drupal specific questions...
As laebs suggested one way is to create block view and to add it to some region when your page is displayed.
Other way would be embedding the view from template file:
https://api.drupal.org/api/views/views.module/function/views_embed_view/7
With this function you can specify which view and which display you want to embed. You can also pass the parameters this way.
And notice that you have "embed" display type (it may be hidden by default - check view options). If you use it you'll also get those nice "edit view" links when embedding view this way.
There are two ways that I know of without using other modules:
Use the Views Header/Footer area to load another view. Just click "Add" in the Head/Footer area of the Views UI and you should see "Global: View area".
Create a page template and insert the views that you'd like to have on the page within the template using some Drupal API php:
<?php
$view = views_get_view('view_machine_name');
print $view->execute_display('default', $args);
?>

Wordpress - Prevent Post Submission unless valid data

I'm building a custom wordpress theme.
When the user is attempting to update a custom post type ( Product ), I want to perform some validation before letting them save/upload.
Here is what's going on.
I have a series of "Things".
Each "Thing" has an advanced custom field for img and for text.
So my goal here is, if they upload an image but don't fill in the textbox, to not allow them to save/upload the post. This also works in reverse ( if they provide text but no image ).
So right now I have hooks in 'save_post' that perform the validation and set notices at the top of the screen letting them know what they did wrong. However, this really doesn't work because 'save_post' is called AFTER the post is saved. Even if it wasn't, I still don't have any way of stopping the post from being saved anyways. The most my implementation does it let them know in hindsight that they messed up.
So, how do I accomplish this task?
I think you can do this with the content_save_pre filter.
http://codex.wordpress.org/Plugin_API/Filter_Reference/content_save_pre
The answer ended up being to use Advanced Custom Field's provided filters.

Define function name with text field

I'm only really a novice with PHP (and I know I'm sortof trying to run before I can walk), but I would like to know if it is possible to define a functions name via a textfield.
Currently, I am working with Wordpress so I can use add_option to add something to the database to store data, etc, which is handy. My idea is for a slideshow plugin which allows you to have unlimited slideshows.
It would work by typing the name into the text box then clicking the submit button to store the name. This name would then be given to a function which can be used to display that specific slideshow. Is this possible?
Sorry if this seems confusing. I know what I want to achieve, I just don't have a clue how (but I am willing to learn). Thanks.
Why do you need new functions? Sounds more like the same funxtion with different arguments, which can easily be your textfield value
1.your plugin admin page allows naming and creating slideshows, like creating a post or a gallery with a title, and adding images.
2.you place a function call in your theme where you want a slideshow to appear:
if(function_exists('display_slideshow')){display_slideshow($slideshow_name)};
3.the function display_slideshow() is included in your plugin file.
function display_slideshow($slideshow_name){
//get slideshow stuff from the database,
//using the name of the show passed as arg
//write your html and php to show the images the way you design
}

Fb like share box in drupal website

I am making a drupal website and have a content type "quotation". The standard way of taking input in drupal is going to the create content in the menu which is not very user friendly considering your normal user.
I want to have an option to create content (i.e quotation) like in facebook, twitter or any other social networking site. A share box where someone can type in his status and can directly create content.
Also, I have two vocabularies associated with my content type and I want to accommodate them as well while using minimum space. So, how should I go about the problem.
Is there any module in Drupal which can help me in doing so or I have to write Jquery code myself.
two vocabularies associated with my
content type and I want to accommodate
them as well while using minimum
space.
Lol, sounds tough. If you want to use minimal space you'll need to simplify the workflow, ie, remove a vocabulary or 2.
You can also do something like this:
$('#node-edit').focus(function (){
// set your node form vocab to display:none and then show them when user actually uses the form
$('.vocab-wrappers').show();
// set your node form buttons to display:none and then show them when user actually uses the form
$('#node-form buttons').show();
});
To hide the vocabularies/buttons until the user is editing the content.
To get a facebook like effect, I suggest you use: http://drupal.org/project/formblock
This should get you the form and the ability to place it anywhere.
You can use form alter to hide certain parts of the form, or a form alter module, there's various options if you look in drupal modules.
http://drupal.org/project/nodeformcols
You also want http://drupal.org/project/auto_nodetitle to make the title optional, and hidden from the form.
Lastly, theme the node form in CSS/JS, making the texarea smaller and whatever other stuff you would like, recommend setting display:none on the field labels.
This should give you the correct idea for making a decent facebook-like form setup.
This should be possible:
http://drupal.org/node/464906
I've never tried it myself though.

Resources