Drupal : How to export node content to other website? - drupal

I want to fetch contents from my Drupal site and show it on another site using CURL. I already have a module that creates a URL (menu) in Drupal and outputs the requested node using node_load() method. This way, I can select which specific fields to output to the requesting site.
However, I also have a module that alters the node's content. What is does is when a node is viewed, it looks for the img tags in the content and replaces the source attribute with its thumbnail version. In this module I look for a specific attribute of the node :
$node->content['body']['#value']
And replace the img tags if present..
My problem is when i call node_load() in the menu I defined on the first paragraph, it doesnt have that $node->content['body']['#value'] that's why the image tags are not replaced..
Thanks!

Use node_view to theme the display of the node and invoke modules changing the node output.

Related

Drupal page content

I'm new to drupal and reading through docs, but hoping to get an explanation for something.
I have a page called page--type-home-page.tpl.php.
Part of this page prints render($page['content'])). I want to remove something that is rendered as part of the page content from the page, but don't understand where this comes from and where/how to look.
Thanks!
Assuming you're talking about Drupal-7
Well the $page['content'] contains a string, which is a rendered version of what's injected into the content region of your theme.
By default, the only block in this region is the "Main page content" block that is generated by the Drupal core. Many things can generate this content but it always pass through the menu API. For instance, if you're viewing a node, the URL used is: node/12. The node module declares a menu entry for node/%node, this menu entry contains a callback function that will render whatever the module wants to render. The module, then, may use different strategy to render it's content from a simple function to a complex imbrication of templates.
The key to alter what's in the box, sorry, what's in the $page['content'], is to know what is rendered and to understand how it's rendered.
If it's a node, first you want to look if you can achieve your goal through the display settings of the content type. admin/structure/types/manage/page/display: And this is true for all entities (users, comments, taxonomy term etc.) Because this is the first thing the module of these entities will put together when they'll try to render your content.
If this is not enough to achieve your goal, you can look into the module that renders the path to see if it hasn't a .tpl.php. You'll be able to re-use it in your theme. You'll want to copy/paste the file in your theme and edit it.
If the module do not have a tpl file to override, try a template suggestion: here's a list from Drupal.org
Ex: node--type.tpl.php
If all this doesn't satisfy your need, you'll have to dig into preprocess functions; Those functions allow you to modify what's in the variables passed to .tpl.php files. That's a little more advanced and I recommend you to read this previous stackoverflow question/answer
Simply, don't use that $page['content'] which prints all content, but place your custom template code instead and print separate field values where you need them like:
<?php print render($content['your_field_name']); ?>
https://drupal.stackexchange.com/questions/30063/how-to-print-fields-in-node-tpl-php
If you want to do just simple styling, like excluding some field you can use content type display options like mgadrat explained, but if you want to use some complex styling, with totally custom html this solution is easier.

ShareThis button directly in Drupal's tpl.php files

I only need to show custom button for sharing on nodes, but I need to put a different button on a lot of places (block quote, view result, image in node...) and to share just that part (probably with anchor tag suffix in the url). When the user clicks on the button, the modal/popup of ShareThis should be shown.
Is there any way to implement this directly into tpl.php file?
There is an example of the similar implementation of AddThis, something like this I need from ShareThis:
<div class="addthis_sharing_toolbox" data-url="THE URL" data-title="THE TITLE"></div>
It is not necessary for me to use the module, so any idea or possible aproach to this is welcome.
Looking at the following link: http://support.sharethis.com/customer/portal/articles/464452-integration-with-a-website you could add the javascript to the html.tpl.php file and the class in the node.tpl.php file or a custom block.
You can add any kind of code to template files of course. If it's just for specific content type add it to node template. And if it should be added for all (or many) content types (outer template) add it to page.tpl.php...or most outer if you want to place some content to i.e. page header - html.tpl.php
There you can put some if statement to i.e. display it on every node page except some...

Drupal generates long links

My drupal site generates long links like:
example.com/drupal/blog/what-we-do/solutions/about-us/
This link works and shows the blog page:
example.com/drupal/blog/
how can i get rid off these kind of links?
Disable the path module in your Drupal installation.
If you want to keep using the path module and delete only some of your aliases visit the page admin/config/search/path and delete whatever you want.
When you create new content you can uncheck the automatic alias generation and blank the text field where you write the alias.
You will still be able to access the content by using node/[NODE_ID]
If you want to do that automatically depending on the type of content, I think you can use pathauto
The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias.

Drupal Lightbox issue (not jQuery lightbox)

I am having a issue in Flag_list module, can anyone please help me out how to put a flag list and how to view it please?
The module has very good description how to do it : http://drupal.org/project/flag_lists
How to use:
Install as usual.
At admin/build/flags you will see a flag "fl_template." This is a default template flag provided by flag_lists. You can edit it to make changes to list messages and to assign it to node types. This
template will be used only on types you assign.
You can create new templates here: admin/build/flags/lists/template and apply them to other node types.
A template can be assiged to many node types, but a node type can only have one template assigned to it.
Enable the "list" block so that it is displayed on your content. The block will only be visible if the content is listable and the user has permission to create lists. That is, the node type must be assigned a template, or the block won't appear. Further, you should enable the link to create lists in the block's config.
Create new lists using the link in the block.
See your lists and listed content at user/[uid]/flags/lists

Drupal excessive menu parts

In a module development (webtv) I am providing a generic block that can be configured for its contents (playlists). On the configure form there is a list of added contents (playlists) along with links "add new playlist" and "edit" existing one placed next to each entry. As the block configuration path is: "admin/build/block/configure/[my_module_name]/[block_delta]".
And I am expecting to add/edit playlist form on a separate page and should be accessible on:
admin/build/block/configure/[my_module_name]/[block_delta]/playlist/add
and
admin/build/block/configure/[my_module_name]/[block_delta]/playlist/[playlist_id]/edit
For this I added two entries in hook_menu with page callback as drupal_get_form and page argument as form defining function.
After clearing cache and running cron, links does not server playlist add/edit page but redirects to block configure page.
What am I doing wrong? Is it possible to extend block configure page into sub pages?
The maximum allowed menu parts in a drupal(6) URL are limited to 7. In my problem I have quoted paths with 8 and 9 parts that was the issue.
admin/build/block/configure/[my_module_name]/[block_delta]/playlist/add
admin/build/block/configure/[my_module_name]/[block_delta]/playlist/[playlist_id]/edit
In Drupal 7 the limit is expanded to 9.
It can manually be changed in the file drupal/includes/menu.inc as define('MENU_MAX_PARTS', 12);

Resources