Drupal custom field customization - php

I am using Drupal 7.
I created a custom field for article nodes, which is a text field, with unlimited values so it's essentially an unordered list. I want to be able to customize the area in which the new field is displayed, but no page.tpl.php it renders under the page content, with the body. The new field does not create a new block in which I can edit. I want to limit the containing div to 350px, and then place a 300x250px ad to the right. So the custom field list on the left, with an ad on the right. If anyone knows a way to doing this rather than finding the div ids and sloppily overriding the CSS to do this please let me know.

I'm not sure your use case and requirements are completely clear to me, but it sounds like you might want to read up on "Render arrays", a new-in-Drupal 7 feature which allows more fine-grained control of content output/display. This is part of the Drupal Core and the official documentation might be a good starting point, but there are many other articles and tutorials (use: "render array" Drupal <-- your search on Google) which might be helpful.

Related

What is the best way to create page in Drupal 8 so that I can then add these posts with images?

I have a Home page on the Drupal website (such as is created after installation), but I still need to create this page:
What is the best way to create a page so that I can then add these posts with images?
I am just starting to learn Drupal and have heard so far about such ways of creating pages:
1) in admin toolbar: Content / Add Content / Article
2) in admin toolbar: Content / Add Content / Basic page
3) in admin toolbar: Structure / Views / Add Views
Which one should I use? Or maybe there is some other option that I don’t know about?
P.S. At the moment I am more interested how to create empty page on which I can then add posts later, and adding posts it is another question.
Welcome to Drupal.
Drupal ships with the default theme which won't look nice but it does its job in the right way. Now if you want to create a better UI/UX obviously you should create a new theme. But before that make sure to read and understand the concepts behind Drupal. Drupal docs are your first friend.
Drupal Documentation
Drupal considers everything as nodes and that's how Drupal got its power. As you mentioned, Articles, Basic Page etc are called content types and they can be used to create a particular type of content.
Now for your purpose create a new content type and add the fields you need. From the image above I can say your content type needs Title, Image, Category and Date. After creating content type you can create as many contents as you want under the content type you just created. Consider each card in your image as content.
Now you can use a Drupal Core Module Views, to perform DataBase Operations without writing single code. Yes, you can select fields, sort, order etc with Views UI and display it in a page or a part of a page (Block).
I would say just try this out in the default Drupal theme and when you understand how this works, you can start creating your own theme for your project.
Theming Drupal
There is a lot of resources available. But you have to make sure what you are asking is whether you actually need. It will take some time, but it worth.
To build layouts for homepages on Drupal 8 you best friend is https://www.drupal.org/docs/8/core/modules/layout-builder
To build the content blocks inside your home page, you should start creating nodes on a node content type to hold your information. For instance: news content type, with a title, a body, a date, and an image.
For every node type, ex. news, work on the preview display, full display, and any other display which makes sense. These displays can be used later in the Layout Builder directly or in Views, referenced below.
If you wish your list to be dynamic, such as the last 10 entries are shown first, then use a view to hold the content sorted and filtered as you need.
In a nutshell.
Create a content type for your article/news.
Modify the displays of the content types to have at least a summary and full view.
Create the content itself to have something to see.
Create the view (block) to filter and sort your content.
Create a page layout (this makes sense for landing pages) which places your new view and any other content you need in any disposition.
This is roughly what I would do. The steps described above contain many intermediate steps. If in doubt, check the docs.
I hope that helps!
First, decide what will you display on that page. Is it content in some existing content type (article maybe) or you want to crate new one for this purpose.
If you need new one then create it (Structure -> Content types -> Add content type).
Then check what fields will you need. I.e. image, some description text. Add missing ones.
Create few nodes (pages) in that type so you could work with them.
Then for displaying you should crate a view (Structure -> Views -> Add view). It can be a page view (you are displaying only that content on page) or block view (this is just a block among some others). If you create a page you could visit it and if you create a block you have to add it to some region to appear on page (Structure -> Block Layout).
Inside your theme you should create templates for this page/block. Turn on twig debug mode so it will show you hints - what templates are used and how can you name yours to override default ones.
Adjust CSS to make it look like you want it to look.
Find some tutorial(s) for the details
Previous answers have given the flow of the work you should go through, I would like to add some resource that might help you achieve this.
Creating content type and fields: https://www.drupal.org/docs/administering-a-drupal-site/managing-content-0/working-with-content-types-and-fields
https://www.drupal.org/docs/user_guide/en/structure-content-type.html
View and View modes: https://www.drupal.org/docs/user_guide/en/views-concept.html
https://www.drupal.org/docs/8/api/entity-api/display-modes-view-modes-and-form-modes
Handling block of the view: https://www.drupal.org/docs/8/core/modules/block/overview
Feel free to ask if any further explanation is needed.
Thank you

Implement Custom Search Plugin for Joomla

I would like to implement a Custom Search Plugin for Joomla 3.5.1. I am new to Joomla and still busy getting my feet together.
I recently implemented a plugin that adds custom/extra fields (5 fields, free text inputs) to an article in Joomla 3.5.1. I followed their tutorial on how to get this right and so far so good. This plugin saves the extra/custom fields in the #__user_profiles table as per their tutorial. I could obviously save it to a different table but since I am learning, I kept it simple. This plugin works perfectly and I can capture the extra fields and saves successfully and the data is saved along with the article id being edited/created.
My next task is to create another site/front-end "search" (or smart search) plugin. This plugin must group the 4 field's values and provide them to the user in the front-end as selects/dropdowns.
Is there someone that can give me a lead on how I can archive this. Must I implement it as a search or smart search plugin? Is it even possible to archive what I am trying to archive?
This search plugin will only appear on one page but that I know I can config correctly once I've a plugin. Once user searches, the system must post back the selected options and I will search the "#__user_profiles" for any matching profile_key vs profile_value and collect all user_id (article_id) and get these articles from contents table and return this list of articles to the front-end as search results. Anyone can help me into the right direction?
I tried their tutorial of creating a search plugin but I seem lost, mostly I don't know how to dynamically provide my selects/dropdowns with that info saved in the #__user_profiles table.
Please assist in anyway possible...
I don't think that this might be done without modifying core 'search' task. My advise is to advise search view and include extra filtering, then write own 'search' task which allow you to read this data and provide additional results.
By writing just search plugin you can only extend search results by data which is stored outside default Joomla! tables but nothing more.

Drupal Commerce - Load drupal variations images instead of a select box

I am not a beginner with Drupal, but I am a beginner with Drupal Commerce. I have used Ubercart since this project.
Actually, If I create a product display, and then a few variations under this product, Drupal Commerce automatically creates select box with titles of the other variations. This is quite useful for almost all the e-shops, but not for this one. I need to replace select box with titles with just images, on which customer will be able to click on, and select variation type just by image.
I think that there is almost all the functionality in drupal commerce kickstart which I am using right now. But I do not know how to achieve the result. I have already tried editing product view, but was not able to make it working. I have also searched through core modules of drupal commerce in code, because I think that there should be just an array function with result of titles, but did not found something like this yet. I have searched whole internet to search for solution but did not found anything useful.
In some threads peoples use to solve similar problems with for example colors, to give the ability for customers to see the color squares instead of color select box, this is achieved by module, which some of devs written. Maybe I can edit this module?
Also, I have never ever created a module, I am a bit lost in drupal codes, but tried it before.
Here are the attachments for better vision:
http://ofca.sk/temp/printscreen.png,
http://ofca.sk/temp/result.png
Any advice will be greatly appreciated; I just need to be pointed to the right direction,
You can achieve this feature, the same way than Commerce Kickstart v2 does: http://demo.commerceguys.com/ck/tops/drupal-commerce-hoodie - note the color selector at the right middle.
This is done using Commerce fancy attributes module which allows you to render color or image selectors that come from a taxonomy:
This module provides a "Rendered term" attribute mode, that shows the rendered term instead of a radio button (degrades to a normal radio button when JS is off) on the add to cart form.
You've got a video demo of this module with a step by step to configure in http://vimeo.com/44308580
Thank you for an advice, but I still had not been able to make it working with fancy attributes module. I used another way using taxonomy and a few views, which done almost the same.
But I still think, It is achievable by Fancy Attributes.
Thank you again
I have created a module for this case: https://www.drupal.org/project/commerce_options_as_images
I use it on my projects.

Jooma 3.1 Templating - Tutorials/Documentation?

I am to develop a Joomla 3.1 Template. The template should consist of a static header and footer, as well as multiple pages, all of which need their own styling. Further, the client would like to be able to add 'events' to a specific listings page. Customers should be able to book said events via a simple form.
Thanks to some really basic guides, I have the header and footer down, as well as some simple template options. However, I am now running into some problems;
How would I approach the content section? Ideally, a page would consist of multiple, editable sections. The client would be able to edit said sections in the backend without having to deal with or accidentally changing the layout or styling of the page itself. Since there are multiple pages, I obviously need different views/containers for each of them. Is this possible and if so, how?
Another problem is the documentation, which I found to be very lacking. Even google only got me so far (basic structure, index.php, templateDetails.xml and so forth). Are there any other resources I may have missed or do I really need to refer to other templates (most of which, obviously, aren't free) and use var_dump all the time?
Writing this, I just realized that I could theoretically build a template for every single page but ... that surely can't be right, right?
If someone could provide a basic outline or at least tell me how you personally would tackle a project like this, it'd be very much appreciated.
All the best
Edit;
I just found some video tutorials but since my bandwidth is limited, I cannot watch them. Please take this into account when writing an answer. Thanks.
I have only one word for you :
GANTRY :D
gantry-framework.org
Joomla revolves around menu items that point to components. For each menu item, you can assign modules to different positions within the template to create a unique page. You only need one template if you really understand how Joomla templating works.
Joomla has very good documentation here - http://docs.joomla.org/
Few things to remember -
Component - this is a type of content or app of sorts. A component will define what content is and how it is displayed. This can be anything from blog articles and categories to an event registration system to a message board or social network. Menu items generally will point to a view in a component.
Modules - these are used to display additional content around the component output. This can be a menu, or a login box, or a weather widget or anything else you can come up with. Modules can be assigned to or excluded from the various menu items on your site.
Plugin - plugins are used to change the final output on a site. They can be used to insert Youtube videos, or forms within content, or even to alter the meta tags on a page.
Understanding how extensions work is an important first step. Once you get how those work, learning how templates and template overrides work will give you most of what you need to know to build a basic Joomla site.

Drupal 6 Layout issue

i have recently started to learn drupal 6. I dont have any previous experience with drupal.
I was asked to implement a page on existing drupal site with the following structure.
a sopping page which will have an thumbail size image with lable and a quantity text box. This pattern will repeat for 10 products. At the end of the page i should have a submit button which results in sending an email with product and quantity to dedicated email address.
If its just a form then i can use webform but the requirement is having an image for every product.
I am not sure how to implementn this...can someone guide me in the right direction please.
This is what i am trying to achieve(http://dontikurthi.com/sample.html)
thanks for the help in advance.
Cheers
R
For the image handling, I suggest ImageCache. If this is going to be a shop, use Ubercart. It's an extremely powerfull shop system with lots of functions and extensions.
It's hard to recommend a single way since Drupal offers many ways of doing it. I would go with CCK (let's you create your own content types with as many fields as you want) and/or Views (pulls data from many different areas of the database into viewable form, highly customizeable and on of the first modules to install together with CCK). Create a new content type with the help of CCK and create a view that displays this particular content type in a fashionable manner. That should get you pretty close to the image above.
When creating a form with webform, you add form components, and you can add "markup" type component: it describes itself as "Markup allows you to enter custom HTML or PHP logic into your form."
So, to add a picture above or below a form item, just add a markup and put the appropriate HTML in it.
eg <img src="http://localhost/picture.jpg " />

Categories