Where to create gutenberg block - wordpress

This Gutenberg update looks sweet, but it's immediately frustrating trying to follow any of the documentation.
I started with the very simple looking tutorial that is the first result on Google. It has code that looks to make sense for what I'm trying to do here. Great.
Except it says nothing about where to put this code to make it work.
Other tutorials are all about "download our plugin and we'll create one for you" - but I don't want to add that huge nest of code when what I'm really looking for is a fairly simple static block of code I can have users drop into a page.
Back in the day we'd just register a short code in the functions.php file and call it a day.
Can someone explain to me:
Where to put this registration code?
Where to put this JS code it references?
If I'm somehow going about this with a huge misunderstanding of how Gutenberg works?
Thanks

To actually solve this properly would need a couple of chapters of a book... but here's the very condensed answer.
Taking a very quick look at the link you shared, the code should be put in a plugin as there are calls to the function plugins_url(). So you need to first create a plugin. It's not difficult to build a simple plugin but it does take a bit of time getting used to how things need to be registered and how everything is glued together (that's why I said that a proper answer would take a couple of chapters of a book :D).
Once you have the plugin, the code should be within the plugin (or in any PHP file that is included by the plugin) and the JS file should go inside the plugin directory in a folder called step-01
There's a git repo from WordPress with some Gutenberg examples. I haven't looked to hard at them, but It might be a good idea to follow the code in there with the tutorial of how to build a plugin (and the WordPress code reference site opened too :D). If you are going to be developing things for WP, I recommend you to get Zeal or Dash to be able to browse the documentation in an easy and fast way.
Edit
I just found that you can create the scaffolding with wp cli. Wordpress has a tutorial on how to use the wp scaffold block command here.

Related

How do you write code on wordpress?

I have just started experimenting with WordPress, but I have not been able to figure out how to write any code whatsoever. All it gives me is built in blog stuff, and I don't want that. How do I write code on WordPress?
Well, what do you want to achieve?
Are you trying to write code that performs a function that the WordPress core doesn't provide? If so, then you should start by reading Writing a Plugin.
If however you'd like to design your own look and feel, then you'd need to create a theme. The best way to do this would be to write a child theme. Start by reading about Child Themes.

Where is the theme function in drupal?

I´m trying to follow this steps:
https://www.drupal.org/node/2025313
This is my first day in drupal and I have a problem in the first step =(
This:
Identify the file your theme function came from (theme.inc? a core/modules/color/?)
How I can find this "theme function"? I was looking for into a files of the project but I cand find this....
I get this project from other person and I can´t ask him "ey, where is the theme function?" Maybe I have wrong concepts and I don´t know where search...
Can someone help me?
Someone knows what I search? Is a funtcion? Is a file?
So the page you're looking at shows how to convert a tpl.php to a html.twig. This is showing you how to update a Drupal 7 theme to be compatible with Drupal 8.
Assuming that is in fact what you're trying to do, you will normally find Drupal 7 theme templates at sites/all/themes/YOUR_THEME_NAME/templates. Once you navigate there, you should see files ending in tpl.php. Inside these files you might find a theme function being used. You can identify them as they'll look something like function theme_YOUR_THEME_NAME_hook($variables).
What is a theme function?
A theme function is a PHP function that exists to provide HTML that is can be customized by themes and modules.
Here is the official list of theme functions. You can find a lot more information on Drupal.org, but here are a few starter links:
1. Theme API
2. Using the theme layer
3. Theme hooks
I would highly recommend reading a book on theming before tackling anything else. Drupal has a lot of depth, and if you're truly on day one and already converting themes, this will serve you well. I recommend 'Using Drupal' to understand the basics of Drupal, as a lot of Drupal development can be accomplished through the User Interface. Then move onto 'Drupal 7 Development by Example Beginner's Guide' to gain an understanding of how and when you should delve into actual code development.

Adding a CMS (wordpress) to a website?

I have made a site using html, css and javascript and is only on my local machine and have not put it onto a server yet, but i was wondering if i could use a cms on this site like wordpress? The site is only 5 pages but i have done all the styling myself.
Would i just have to install wordpress to the server and add the files there maybe? Or is there a lot of changes needed to make this work?
I have very little knowledge of PHP but i am a quick learner if that counts for anything.
Thanks for help.
Simple answer: yes
More complicated answer: why?
If your site is only 5 pages, and you've custom designed and built your layout, then I'm not sure what WordPress will add for you.
That said, if you want to add a blog or the like, WP would certainly be nice to have.
If you want to go that route, you have a few options:
use WordPress for everything, using the 5 pages you made as 'pages' inside of WordPress. You'll have to modify what you built for that to some extent.
leave the 5 pages as-is but add WordPress 'next to it' and run the blog/cms content from there. It can look the same, or maybe you want it to look a bit different.
leave your 5-page site as-is, and use WordPress or another CMS product on a separate server. You can set it up as a subdomain and then either install your own, or leverage something like Posterous or Wordpress.com
The short answer to your question is:
it will take some effort, you won't be able to just drop the files and install wordpress and have everything work immediately. With some work, though, it is definitely possible.
If you've done the styling and you want to incorporate that into wordpress you'll have to go through the process of creating your own theme. http://themeshaper.com/2009/06/22/wordpress-themes-templates-tutorial/ Try this site to see what that requires. Alternatively, google "creating your own wordpress theme" or something similar.
It will require some extensive PHP work, but a lot of these tutorials have already done that heavy lifting for you. In any case, it will be worth it for your to pick up some PHP skills, enough to follow along the tutorials.
I had to do this myself and what you can do is integrate your design into an existing design. You could just create your own theme, which takes some time but it is the correct way to do it.
http://yoast.com/wordpress-theme-anatomy/
I knew 0 php and I was able to create my own theme in a few hours. Best of luck.
I'm not sure what you mean "add the files there", I assume you means that use a WordPress-based website to display your site, then you can simple create a page by WordPress and then link this page to your site.
But if you means to create a wordpress theme which based on your existing site, then you can search a tutorial and follow it to create a wordpress theme by yourself. Making a wordpress theme will needs some PHP work, but not complicate, wordpress has very detailed documations and API.
I would suggest using the Umbraco CMS for it. The advantage is that you start with an empty site, add your css, js, and create your own content types, paste in your HTML for the templates, and you're ready to go. It is a perfect CMS for few page sites to larger sites and also has a great community around it, including lots of documentation and screencasts. Templating is done with the Razor syntax, very easy to learn and lots of documentation. You'll need to have a Microsoft-based server to host it and this may be a barrier depending on your hosting scenario.

From static blogging to manual html editing?

I have my site done with WordPress. It's been like that for a few years.
Now, I have started to look for other options. WordPress has all these things I don't really need. One option would be static blogging. Generate the content locally and deploy the generated content to web with rsync, for example. There is tools like Jekyll, Hyde and Octopress for this.
But even Octopress seems like an overkill for me. It really feels like that. I don't need all those plugins it comes with. I'm building an image heavy site for myself, just a place where I can put my drawings that I create with my tablet.
So what if I would just manually edit HTML-files, where every file would become "a post" and make an index for them at root of my site? Come to think of it, I could work faster with this type of solution, even compared to Octopress. I could have a blank "post template" as raw html and set it as fill in snippet in TextExpander. In there, I could fill all the details for that html file like the title tag and so on.
I'm not really a coder. I draw things and write stories. In spite of this, I somehow have managed to work my way around with WordPress and recently, with Octopress.
I'm just thinking why Jekyll or Octopress or Hyde or Cactus would be a better fit for me instead of manually editing html files, and calling them "articles" or "posts"?
Thanks for any views or answers.
Why do you want to go to static html?
If you have problems with using too many resources, you should add a caching plugin to your WordPress install and that will help greatly.
Most of the time you still want some "dynamic" functionality that happens every time you add a page. For example you probably want to have a RSS/Atom feed so that people can subscribe to your site. And you want that automatically updated when you add a new page. You probably also want something to generate a sitemap file for the search engines to index it better.
These static site generators are able to do that well, so I would recommend using one.

Is WordPress suficient for this project or should I use a framework or a different CMS?

I am a web Designer that recently decided to expand into developer waters as well :). What I have in mind is to build an elaborate portfolio site that will also contain a blog. The sites sections will be standard for such a project - something like Home, About, Portfolio, Contact and Blog.
The Home page will contain some static parts but also feeds from the latest additions to the portfolio and the blog.
The Portfolio page will have sections on the different types of portfolio pieces (like logo, print, web etc).
The About will be completely static.
The Contact page will be static and will have a contact form.
The Blog page will basically have your standard WordPress blog structure.
At first I was thinking of doing the whole thing in WordPress (since I already have some experience with it) but what got me thinking about different options was the portfolio part. I want the portfolio page to be quite differently stylized than the blog page and yet I want to have the possibility of doing quick and easy additions to it trough an admin panel.
So please give me suggestions and direction about what would be best for me to do? Is this thing possible with WordPress? Should I instead code the whole project with CodeIgniter (or a similar framework)?
I am quite good with HTML & CSS. Comfortable with jQuery. Trying to get better with PHP :).
I am willing to learn and improve and wouldn't mind trying a CMS or a Framework that Ive not had experience with before.
Thank you.
Wordpress is more than sufficient. You might want to find some plugins that allow you to add special content like videos, scripts and other things to portfolio pages. Also knowing html, css well is important if you want to build or modify a theme a lot to your liking. It is also very helpful to know some php if not be very experienced with it. MySql is helpful as well but not as need to know.
This Wordpress PHP function sheet is very helpful at times.
The Wordpress Codex page is also very good. Not an end all be all, you'll still need to know how to do things on your own, but it defiantly will get the ball rolling if want want any custom functions, or want to modify functions.
If you know wordpress a little bit, I hope you will able to make your desired project. Using wp you can do several types of project.
Read some wp books or tutorial and learn wp functions.
Essential wp functions sheet https://codex.wordpress.org/Function_Reference
I hope it will help you.

Resources