I know that this is bit of a conceptual question but after searching alot i am unable to grab the concept that is why i am hoping to get help from this platform.
I often need to change some markup or styles etc on the elements let se in $page['highlight']
When i var_dump any variable in any .tpl file it gives just a basic information. Let say i have to add additional div element in a content that is set to be rendered in $page['highlight'] region. What would be the way that i grab that element and alter it before it rendered on page.
The same case happend to me when i made a page view in drupal. I had a custom .tpl file which was displaying the view and all records were getting displayed by a single variable like
print $rows
I am not specifically asking for the code but it would be helpful to many other users including me to grab the concept with a little example.
Thanks alot.
There are different ways to do the same things you say.
In views, you can customize your results by Theme: information option. Is's in the bottom-right part of the view configuration. Here you have the option to create a new file and customize the view results. In your case you need to create a new Row style output: (it contains the value of $row variable).
Here is a tutorial: https://www.ostraining.com/blog/drupal/views-templates/
About the $page variable. You have different options depends on the context. For example if you need to add a in all pages, the best option is to edit the page.tpl.php in your theme.
Another option is to change the template.php of your theme, but only if you need to add html in some cases.
Hope it helps.
Regards.
Related
I am wondering if there is anyone out there who knows about Views in Drupal 6, specifically the Ticker aspect that could assist me with the following issue:
I have to create a news ticker that reads in the titles from a specific content type and then prints out those titles in a horizontally scrolling fashion. That is the easy part, I have gotten that to work. The part that I am having issues with is I then need to format this ticker to be a specific font, placed in a specific location on the webpage, but still take in the feed from the content types that it is supposed to. Does anyone know how to use this/ has anyone done anything that works similarly to this in the past?
I would also like to apologize if this is a dumb question, but I do really need assistance.
Thank you
I'd suggest enabling a views block which will allow you to move the view into any region. Defining a custom region will allow you to add the view anywhere within your site. You can also use views_embed_views() which allows you to reference the view directly. Your view will likely require additional JS to load for the ticker function to work and a modified version of using views_embed_view() with slideshow should help.
I know the title is messed up, but basically I have: news.php which is kind of a dashboard where I get all news from DB and I can perform actions on them (update, delete, insert new) and also I display them in a traditional way (tables). The problem is I want the title of the first news to be displayed on my homepage(footer), but when I include the news.php file withinclude(), the hole code it's included and on the home page I get all the things I have in news.php, all the news, the buttons (edit, add, delete) and everything else. Is there any way of including one .php file but not displaying it ? I want to create a function that only displays the title of the first news but I can't because the hole code is imported and displayed.
Thank you for your quick answers. Having only this small problem, I'll just create another file where I get the latest news without using frameworks
You need to create a function library so that you can call specific segments if you want.
But here's a quick shortcut. copy news.php into news2.php. go into news2.php delete all the parts you don't want; include news2.php instead
You could try making another single file called firstnews.php which would only retrieve that particular first news item and include that.
You should maybe read up on MVC frameworks, its a good way to seperate data retrieval, manipulation, and then actually showing the data. For example one php file would hold a function that retrieves all news item, and another function that only gets the latest news article. Then the actual file which shows the user data would simply choose which function it wants to use.
Its a lot to get into, but the codeigniter framework is a great way to get familiar with MVC frameworks and it will open a lot of doors for you.
CodeIgniter Homepage
Manual on how to setup and use CodeIgniter
For now though try just making a seperate php file that only retrieves the latest news item instead of all of them and include that.
Hope this helps!
-Gui
I have a website that needs to have a variation of pages.
For example:
website.com/variation1/page1
website.com/variation2/page1
website.com/variation3/page1
All of which has the same DB and has the same function. The only difference is that these variations differs in page template ie. Header, Footer, Content, etc. This is for the purpose of analyzing page visits.
With that, what is the best way to do this? In Yii, there is a common layout used so header/footer depends on the layout. In this case, the header/footer should be specific to each page so the user can just modify the header/footer/content of a specific page without affecting other pages.
So, again what is the best approach for this?
Thank you in advance.
EDIT:
I think I know what I'm looking for here:
Is there a way to override/add from a layout the header in a view file?
Create Three different layouts say variation1.php, variation2.php, variation3.php, then based on the action(website.com/variation/pageone) or the parameter(website.com/variation/page/1) change the layout(in action).
I just found out a possible solution to approach page variations.
Under my view directory I created a directory varation which contains the pages i.e.
/view/variation/1/page1.php
/view/variation/2/page1.php
So when I want to render the varations I'll call each in the controller with parameters included.
Ex. $this->render('variation/1/page1') somewhat.
And in each page if you want to use a specific header info you may use
Register Meta Tag
Register Script File / Script
Register CSS File / CSS
Let me know if there are better ways of doing this.
I'm quite new to Drupal and want do some editing of the header. I want a custom toolbar to appear on every page. I've already created that toolbar in a file called toolbar.php. It has a layer which is fixed and will appear on top of every page.
How do I include the toolbar.php in the header template of drupal?
The toolbar refers to $user which is a global Drupal variable and I want to test toolbar.php before publishing it to the site. Is there anyway I can do that?
Regards,
Dasith
Of the two methods above the first is easier if you understand the basic idea of html and CMS templates, the second will be easier if you are a programmer.
First thing to check is that you really need to do this! Can't you restyle one of the existing menus (Primary or secondary) to do this - will make your life (and anyone who works on the site in the future) a lot easier.
The other thing you can do is look into adding an output region, basically something where you put the php into a drupal friendly format and then effectively do a 'drupal print'. This is how the toolbar, search box etc are done. You still need to alter the templates as above.
Yes for sure. If you want to have the html produced by your function/file appear on every page of the site then you will need to over-ride the page.tpl.php file in the theme you are using and essentually add the html to that file.
To gain access to the $user variable, just declare it in your script.
global $user;
open page.tpl.php file in a code editor and save as page-front.tpl.php (with two dashes if you are using Drupal 7.. one dash with Drupal 6) and upload it to your theme's directory. Clear your cache by going to configuration->Performance->Clear All Cache. Then referesh the page. Now your homepage is using page-front.tpl.php as it's template file. Every page will need its own template file. The page machine name comes after the hyphen so the user page template uses page-user.tpl.php. You can edit it as you want. The proper way to really do this is to use hook_theme() to pass variables to the template file. One variable could be the html which creates your custom header.
See also http://drupal.org/node/457740 Beginners Guide to over riding theme output
Since I had some comments on the formulation of my question, I decided to rewrite it completely. And also, I understand a little bit more about wordpress so it should make more sense now.
So, let's start with what I'm trying to accomplish by using a simple example:
Goal:
Make a search engine for some products and link to them using a database to generate the information.
Result:
http://my.site.url/wordpress/<plugin-name> <-- The page with the "search" and "search result
http://my.site.url/wordpress/<plugin-name>/products/<product_name> <-- When click on a search result
Part 1:
I want to make a plugin with the name "plugin-name" Right now, I put my code in
http://my.site.url/wordpress/wp-content/plugins/<plugin-name>
On the activate, I create some tables with some data. Since there is no page yet, I create 1 on the fly using the API call 'wp_insert_post'. I give the name and slug "myPlugin".
So, when I go on the main site, I can see my newly created page "myPlugin". But right now, there is no content attached to it. To do so, from what I understand, I need to create a page in my plug-in directory named "myPlugin.php".
http://my.site.url/wordpress/wp-content/plugins/<plugin-name>/myPlugin.php
So, how do I link the page I created manually and the source file in the plugin directory?
Part 2
When clicking on a link in the search result, I would like to have a page "product.php" and display its information. So, is it possible to create a "temporary url" for the result using sub pages (see result at the beginning)? And if possible, how can we achieve that?
Thanks in advance and I hope it's clearer.
u can find how to create plugin from
http://ditio.net/2007/08/09/how-to-create-wordpress-plugin-from-a-scratch/
in plugin write function for search(as per u r logic) fetch result
create a custom page refer video from www.wordpressmax.com/customize-wordpress/custom-page
in custom pages template in between get_header(); and get_footer(); call search function and display records.
Thats it.
thisMayhem is right. This sounds like a bunch of nonsense. But, if you're trying to make a WP page that executes some custom PHP, look up the WP template hierarchy.
What you can do is this:
create a WP "page" - call it "Search results."
create a template directory file called page-search-results.php (filename corresponds with slug of page from step 1)
put some generic header/footer stuff there (see other template files - most often it's just a question of putting in <?php get_header(); ?> and <?php get_footer(); ?>)
put PHP code in that thar page. in them hills.
if you use a caching plugin, may want to put an exemption for /search-results/
So, when someone pulls up http://your.site/search-results/ - your custom PHP code will execute. It's up to you to make that logic and communication happen - whether via $_GET or $_POST, etc.
I'm sorry you're experiencing some problems. Unfortunately as we say above because it's a 'one off' for a client project we can't support it - it works for them :) Feel free to rip it apart and retest and if you have any success let us know.