wordpress page.php styling and markup - php

I have a couple of questions related to building a custom theme with Wordpress.
1) If the website is made up of pages, I can use page .php to run the LOOP and retrieve content. In this case, is it OK to paste the content (of each page) using the backend of word press - I.e. paste all content and HTML markup into the 'text; . Is this a reliable way to enter content and accompanying markup into the database?
I guess the advantage is that users will then be able to edit the content themselves using the visual Tab.
Many thanks,
P

Well this not a recommended way to do it, but yes the editor is there for the same purpose. I wont be using it this way, because in my experience wordpress editor often acts weird with html. By default auto paragraphs are enabled, so everything gets in its own paragraph, even if you disable auto paragraph it still has some issues. For instance if you add html in the text tab, and then goto visual tab and switch back to html, and save the same html, this time it would be styled differently. Secondly its also not good to allow users to add html from a security POV and you cant guarentee the consitency of the website.
I would recommend using custom fields instead and fetch these custom fields in the through your theme files.

Related

Dynamically Creating pages based on user's input

I have an article website. So far, all my articles have been created by me working with the code. Copying and pasting the code and editing the P tags, H1 tags, etc. This turns out to be a hassle and increases the chance of you making an error. Especially when the article has multiple pages.
Future-wise, I want users to create articles. So this is what I want: User clicks on button that says 'create an article' and then the user gets redirected to the article builder page where they can make an article for themselves. The user will create a name for their article, this name will create a folder on my server...for example: www.example.com/articles/name-of-article. Then the user can write the article. The user will abide by classes I have created for tags, but those tags will not be seen by the user. The user only sees that their content is getting adjusted well based on my CSS template. Also, if the user wants to add another page to the article, they can put in already built buttons...they just have to change the links to those buttons. The user should also have the ability to bold, underline, and italicize text.
Note: Users are working with a pre-built template, not a blank page. The template article includes a recommended panel, showing other articles. The user does not have permission to edit this panel.
I've heard about WYSIWYG HTML editors, but I just want to know if this is the right thing for what I want. Is there something else that can accomplish my task better? If WYSIWYG is the best answer, can it do everything I've asked for?
P.S: My article pages are PHP pages, with HTML and Javascript included.
You don't need to write html codes of articels in php. I would suggest you to use a content management system (CMS) like Wordpress.
What you want is a CMS. Wordpress is the best approach for your needs, but if you can't use it, you can search for other CMS systems/frameworks.
If you want to make/use your own, just remember to do a Template framework.
And appart of your main question about WYSIWYG, yes, you can do all you asked if it can be done with PHP.

Wordpress,how can I convert textareas to use a wysiwyg editor?

I have a question about wordpress. I am creating a web form for branch managers to enter data into a database, one of the fields can contain bullet points so I need to use an editor that will allow the user to use bullets and then convert it to html like the way wordpress handles posts. Is there a way to make text areas use the tinymce editor? I tried using mceTextarea but it didn't do anything. Anyone know how to add editor options to textareas?
(Making this an answer so others can find it.)
WordPress has a function called wp_editor() that creates a WYSIWYG editor anywhere you need one.

Formatting error while publishing the blog from Microsoft Word

I posted this question on wodpress.stackexchange.com without getting any response.
I realized it could be a programming issue in PHP.
I am trying to publish a blog post into wordpress based website from Microsoft Live Writer. Here is the sample text that I added in Microsoft which I published as well.
" Temporary Blog Post
I am adding a temporary blog post here
Let’s see how it goes
Thanks"
However, when I published the post, this is how it looked
/pI am adding a temporary blog post here
/ppLet’s see how it goes
/ppThanks
Notice the \pp tags which is getting added in text.
Any idea the reason behind the formatting error? I thought when you publish from Microsoft word or Microsoft Live Writer, it should look the same as in the Microsoft Word/Live Writer.
Update : I am having the same error when I am posting from other publishing software like Windows Live Writer etc.
By default, WordPress automatically inserts paragraph tags all over the place when displaying ‘the_content’ – this often gets in the way when you’re trying to space out your text, and also creates validation issues (inserting implicit p tag). If you want to strip the automatically inserted paragraph tags from your content, simply insert this line in your template file above ‘the_content’ tag:
<?php remove_filter (‘the_content’, ‘wpautop’); ?>
OR
Use the cleanup_shortcode_fix() function that should help with your issue.
Check out below links for more information,
Remove the p tags auto wrap
Removing <p> and <br/> tags in WordPress posts
wordpress-wrapping-shortcodes-with-p-tags
Disable wpautop
may this help you.
I found this article which seems to deal with the problem, although its very old so my initial question would be what version of wordpress are you using?
To stop wordpress adding the tags simply add:
remove_filter ('the_content', 'wpautop');
To the top of your functions.php
On a side note I don't use the auto publish features of word, I find cut and pasting a document into Ultimate TinyMCE is the best way to keep your formatting, but thats just my opinion.
Paste it in the notepad first then recopy it from the notepad before pasting it to the wordpress editor.
That should do it.
OR if you dont want to use notepad,
There's a button in the editor that allows you to paste content directly from Word. This removes the special formatting Word uses to lay content out on the page and will make things work well on your site. (The button is in the "Kitchen Sink" on the Visual editor and is circled in the image below.) alt text

Drupal - adding square ads to the body of articles

I need to insert a google adsense square box in the middle of all articles on the site.
What is the best approach?
The site is in drupal, so I figures I can hook to the view node function. this way the ad won't be saved together with the article. does that make sense? If so, than the question is how do I ensure I won't have image on the other side of the ad (the ad is aligned to the left and should take 50% of the article width)?
should I be using a block? but how will I know to place the block in inside the block.
So in short, I really have no idea where to start to implement it... How is this thing implemented in all the news sites?
I'd approach it by implementing a custom input filter that would insert the AdSense code (or the AdSense module shortcode, if you want) into the processed text. Once you have that custom filter implemented, you'll have to enable it in the text format you're using for the content type.
For implementing a custom filter, take a look at filter_example here.
This solution is for Drupal 7. The solution which worked for me is that I used the adsense tags format and then used this format to show ads on the site. Note that this line doesnot need any js inclusion or script tags. You just need to enable the Adsense tags format(I mean shortcode). Actually I was getting Ads disabled for admin and for other users i was getting the empty ad with space occupied on page but nothing shown. After different tweaks and experiments I got the following code working for me
[adsense:336x280:XXXXXXXXXX]
2nd parameter is width x height
3rd parameter: XXXXXXXXXX denotes the google ad slot/id.
I hope this will help others.
Ata ul Mustafa
I need to insert a google adsense square box in the middle of all articles on the site. What is the best approach?
From my experience:
On some drupal sites I used simply node editor to put box with adsense into content. For websites with not many nodes its best solution because of:
1) Box perfect fits in rest of content - you can change it manually.
2) Total control of viewed boxes - images, flash, text adds etc.
Etc.
But for websites with many nodes, this solution looks like stupid suicide.
Better option will be change node.tpl file in your theme folder. But there is some trouble. In this file, you have $content variable, with contains all of content in this node. This situation gives you ability to put box up or down of this node. But no in the middle. Perhaps solution will be to divide $content into 2x variables which will contains a half of contents. But question is - how do to it? Or maybe while content from node is saved into database, then you can put some html code with adsense box? And search best position to put box by regular expressions? Or maybe change all of nodes by adding html box directly in database?
should I be using a block? but how will I know to place the block in
inside the block.
As I remember, you cannot put block inside another block.

What's the Best WYSIWYG contenteditable plugin for editing HTML while preserving dynamic PHP/ASP/etc. content?

I'm looking for a contenteditable wysiwyg plugin to put on a web page that lets users edit content with the least amount of unnecessary changes to the manually edited html code, similar to dreamweaver. Most of the ones I find alter the code too much.
Please help.
I'm not sure whether this is possible. However, another method is to let the user change any < div > on the page.
I've used TinyMCE on a number of projects and find that it's worked extremely well as a WYSIWYG editor on sites where I need to provide content management and editing functionality to my clients.
http://tinymce.moxiecode.com/

Categories