Convert codeigniter code to html - html

I have placed a codeigniter code and i want that code in html.Pls help me to do this.
<? echo anchor('login/signup', 'Create Account');?>

Not sure why you want that code (which generates an anchor when the HTML page is rendered - look at your browser page source)
But what that CI URL helper translates to is:
Create Account
I can only assume you maybe want to add attributes to it and don't know how?
For example, you could add an ID and/or class like so:
<? echo anchor('login/signup', 'Create Account', 'id="some-id" class="some-class"');?>
Just make sure you're loading that 'helper' in your controller, or set it to autoload in the config/autoload.php file (which makes the most sense for this type of helper, as it'll likely be used site wide).
For more info on the CI URL Helper, visit here:
http://ellislab.com/codeigniter%20/user-guide/helpers/url_helper.html

Related

How to make a custom Archive page with Wordpress using custom post types and acf fields

I am building a child theme on GeneratePress to create a custom site for a client and am stuck on customizing the Archive pages. I've determined that it will be best to ignore the theme functionality and build the page loops from scratch. The custom archive should take the place of wp/generatepress' standard archive page and function in the same way by showing relevant posts when a taxonomy term is clicked. I need to be able to choose which html tags are used and style them with css. My issue is that I don't understand wordpress dev enough to figure out how to do this.
I have two custom post types, Research and Resources, as well as a bunch of different custom taxonomies that are applied to both or each post type. I'd like to customize the archive page (with archive templates if necessary) so it displays the appropriate Research and/or Resource files when visited.
I understand that I need to loop through all the posts, but I do not know how to grab only the relevant ones per the given archive page.
Examples of loops with example content will be the most helpful. Thank you!!
I chatted with someone on Reddit who kindly answered this question for me here.
They said:
So I wouldn't do it as a template personally (you could), I would do it through having two new files a archive-research.php & archive-resources.php.
Then if the loop is going to be the same on both pages, which I think you said it is going to be (you just want to display the posts from each custom post type), I would use a template part.
So create a new folder in your theme folder called inc or includes and name the file custom_post_loop.php (name can be anything).
Then in your archive page, call...
<?php get_template_part('inc/custom_post_loop');?>
In that file you are just wanting to write a simple post loop in there.
while ( have_posts() ) : the_post();
// Your loop code
// just so you can see this work I have called the title
the_title();
endwhile;
else : _e( 'Sorry, no posts were found.', 'textdomain' ); endif; ?>
https://developer.wordpress.org/reference/functions/have_posts/
Have a look at that link to find out more. But thats the direction to go...
If you really wanted to got the direction you have with the template, you would have to add arguments to your posts loop.
it works the same way but instead of archive.php its taxonomy.php...
However, you don't want a taxonomy-{taxonomy name}.php file for each taxonomy as that would be ridiculous unless you knew all the taxonomies haha and had really specific user cases for them...
so just create a taxonomy.php in your theme files and to make sure its working just add this code to it...
<?php get_header();>
<h1><?php the_archive_title();?></h1>
//then put your loop in from earlier...
<?php get_template_part('inc/custom_post_loop');?>
<?php get_footer();?>

Server Side Includes with variable (IIS 7)

I am trying to build a universal header file that I can include in each .html file on my site. My header contains several dropdown tabs, and one of the tabs is always highlighted (depending on which page the user is on). So I want to do something like a server side include for the header, but I also want to give it a variable so that it knows which tab to highlight, something like this:
<div class="topmenu">
<ul>
<someScript>
if (variable=="home") {
print "<li class='current'>";
} else {
print "<li>";
}
</someScript>
...
My server is IIS 7 and doesn't support PHP, and I don't want to rename all my files to *.asp so that I can use ASP. How could I go about this?
By the extension I guess you would use Classic ASP. Then something like this should work:
<!--#include file="header.asp"-->
You can put this in each file you want to have a header.
Of couse, you should create that "header.asp" page first ;)
For highligthing the tab of the page you're in, there're several methods.
IMHO, I suggest a clientside script to do that. JS or jQuery of course.
You could check the file name of the URL you are in and give the proper class to the tab so it will be highligthed.
Example ( jQuery needed ):
var currentPage = window.location.pathname.substring(url.lastIndexOf('/')+1);
if(currentPage == 'default.asp') $('li.homepage a').addClass('current');
This simple code retrives the file name and, by it, add a class to the corresponding element in your navigation.
Of course this is a conceptual script, you'd better adapt it to your page.

HTML_purifier stripping display:none css from images, even with CSS.AllowTricky set to True?

That title is probably a bit confusing so let me elaborate.
I'm using HTML_purifier to clean up user input, although in this case the only user who will be using it will be myself (its in password protected folders). A long story short I would like to be able to add in image tag code to a web form, then on the page that it sends too use the code to display said image.
However i need the image tag to have css attributes added to it, one of which is
display:block
Anyway by default HTML_purifier removes this, detailed here because of the CSS.allowTricky option. As i understand it if you set the CSS.allowTricky option to True, then it should allow
display:block
However after doing this its still removing it, just wondering if anybody has done this before as i can't find much documentation about it on the web? Its not generating any errors in syslog, so im assuming that its the correct implementation but isn't working as expected.
My code at the moment.
include('HTMLPurifier.standalone.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.AllowTricky', true);
* UPDATE **
The code should pass the config object (which the code already set) to the html purifier object. Putting it together it should look something like this.
include('HTMLPurifier.standalone.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('CSS.AllowTricky', true);
$purifier = new HTMLPurifier($config);
Duplicate of http://htmlpurifier.org/phorum/read.php?3,6724 (solution was passing the config object to the HTML Purifier object so that the config actually got applied.)

How can I configure my route.rb page to redictect to a view

In my route.rb file I currently have:
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
map.root :controller => "test"
how do I direct my index page to direct to something like this:
http://site.com/railstest/test/index.html
or just:
http://site.com/railstest/test.erb
originally it started off at:
http://site.com/railstest/
which took me to the default html page, which has now been deleted. should I change the route or create a test.rb in the view folder, thank you
It's not possible to make a route that goes directly to a view, bypassing every controller.
So you have two options available to you now:
make it as a static html page
create the full html page
save it in /public/railstest/filename.html
use the URL: site.com/railstest/filename.html
note: hard to maintain, and cannot take advantage of layouts.
create a controller that will serve your view
either "script/generate RailstestController index" of "rails g PagesController index"
delete the app/views/index.html.erb that it creates and copy yourview file to that name instead
should Just Work

How to include a HTML in JSP at runtime?

I need to include html or image in a JSP at runtime. I will come to know about the jsp filename at the time of runtime. So I can't able to make the change for a JSP include.
How can I do this?
I am not sure what you mean by runtime? I have done something maybe similar. In the controller I do. model.addAttribute("jspContent", "test.jsp")
And then in the containing jsp file :
<jsp:include page="${jspContent}" ></jsp:include>
Edit:
Read your comment. I guess then it depends on what other technologies you are using. You could add the name to be included to the session and then read it in the Controller that is receiving the redirect. Adding it to the model and clearing from session. Or if you happen to use Spring I just yesterday got to know about this: http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-flash-attributes
Edit2:
I meant something like this, I am not entirely sure if it's suitable, but it's an idea :)
In the controller that is redirecting you do something like this:
session.setAttribute("jspContentFromRedirect", "test.jsp");
servletResponse.sendRedirect(urlToRedirectTo);
And then in the receiving Controller:
String jspContent = session.getAttribute("jspContentFromRedirect");
if(jspContent != null){
model.addAttribute("jspContent", jspContent);
session.setAttribute("jspContentFromRedirect", null);
}
Something like this