zen cart自定义页面

按照下面的路径,添加自己的文件,就OK了

以about us页面为例, 默认模板

\includes\templates\template_default\templates\tpl_about_us_default.php
\includes\languages\english\about_us.php
\includes\languages\english\html_includes\define_about_us.php
\includes\modules\pages\about_us\header_php.php

\includes\filenames.php




我们以About Us为例讲解一下zencart中如何新建页面!

1.在includes\languages\english\html_includes目录中新建文件define_about_us.php

这个文件是要显示的内容,我们可以在后台 工具->页面编辑 中进行编辑。


2.在includes\templates\Your_template\templates目录中新建文件tpl_about_us_default.php
并在此文件中增加如下代码:


3.在includes\modules\pages目录中新建about_us目录

4.在新建的about_us目录中新建文件header_php.php,并在文件中增加如下代码:
add(NAVBAR_TITLE);
$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . ‘/html_includes/’, 
FILENAME_DEFINE_ABOUT_US, ‘false’);
?>

5.在includes/filenames.php文件增加如下代码:
define(‘FILENAME_DEFINE_ABOUT_US’, ‘define_about_us’);

6.在includes\languages\english目录中新建文件about_us.php,并在文件中增加如下代码:



4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录

sql删除空记录
DELETE FROM Content Where [pic_content_first] =””

sql删除null记录

Delete from 表名 where 字段名 is null

火车头

DELETE FROM Content Where [pic_content_first] =""

4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录

delete from Content where [pic_content_first] in (select [pic_content_first] from Content group by [pic_content_first]  having count([pic_content_first]) > 1) and rowid not in (select min(rowid) from Content group by [pic_content_first] having count([pic_content_first] )>1)

excel删除重复内容行

行与行中,某列内容重复,其他列内容可能不一致 此时我们希望以某列为条件,找出重复的内容,把其所在的整行删除。如下图所示

dsfsdfe

我们只需要A列(即:姓名列)没有重复。

操作方法:
1.添加新列E,输入数字等差序列(如1、2、3„„),拖动手动柄就可以。
2.将全表按A列排序。
3.在F2输入公式: =IF(A2=A1,”重复”,””) 拖动手动柄,将公式向下复制到相应行。

=IF(A2=A1,"重复","")

4.全选表,“数据→自动筛选”,选定F列“(空白)”,这样就筛选出没有重复的数据了。
5.复制筛选后的表,把表黏贴到另外的工作表中。
6.将全表按E列排序,恢复数据原始顺序,然后把E列删除

arc4random随机数的使用_int,NSinteger

You usually want to use NSInteger when you don't know what kind of processor architecture your code might run on, so you may for some reason want the largest possible int type, which on 32 bit systems is just an int, while on a 64-bit system it's a long.

当你不知道程序运行哪种处理器架构时,你最好使用NSInteger,因为在有可能int在32位系统中只是int类型,而在64位系统,int可能变是long型。

I'd stick with using NSInteger instead of int/long unless you specifically require them.

除非不得不使用int/long型,坚持使用NSInteger。

从上面的定义可以看出NSInteger/NSUInteger是一种动态定义的类型,在不同的设备,不同的架构,有可能是int类型,有可能是long类型。

With regard to the correct format specifier you should use for each of these types, see the String Programming Guide's section on Platform Dependencies

为了正确的使用这些类型,可以参考String Programming Guide's section on Platform Dependencies。
为了更简单的知道NSInteger和long的大小,我们只需要记住它们的大小总是等于指针的大小,即在32bit系统中是32bit,在64bit系统大小总是64bit。(NSInteger and long are always pointer-sized. That means they're 32-bits on 32-bit systems, and 64 bits on 64-bit systems
objective-c 中随机数的用法 (3种:arc4random() 、random()、CCRANDOM_0_1() )

1、随机数的使用

     1)、arc4random() 比较精确不需要生成随即种子

       使用方法 :

                 通过arc4random() 获取0到x-1之间的整数的代码如下:

                 int value = arc4random() % x; 


                 获取1到x之间的整数的代码如下:

                 int value = (arc4random() % x) + 1; 

 

       2)、CCRANDOM_0_1() cocos2d中使用 ,范围是[0,1]

       使用方法:

                 float random = CCRANDOM_0_1() * 5; //[0,5]   CCRANDOM_0_1() 取值范围是[0,1]

 

       3)、random() 需要初始化时设置种子

      使用方法:

                srandom((unsigned int)time(time_t *)NULL); //初始化时,设置下种子就好了。

Core Data Peristence

//
//  BIDViewController.h
//  Core Data Peristence
//

#import 

@interface BIDViewController : UIViewController

@property (strong, nonatomic) IBOutletCollection(UITextField) NSArray *lineFields;

@end

//
//  BIDViewController.m
//  Core Data Peristence
//

#import "BIDViewController.h"
#import "BIDAppDelegate.h"

static NSString * const kLineEntityName = @"Line";
static NSString * const kLineNumberKey = @"lineNumber";
static NSString * const kLineTextKey = @"lineText";

@interface BIDViewController ()

@end

@implementation BIDViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    BIDAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    NSManagedObjectContext *context = [appDelegate managedObjectContext];
    NSFetchRequest *request = [[NSFetchRequest alloc]
                               initWithEntityName:kLineEntityName];
    
    NSError *error;
    NSArray *objects = [context executeFetchRequest:request error:&error];
    if (objects == nil) {
        NSLog(@"There was an error!");
        // Do whatever error handling is appropriate
    }
    
    for (NSManagedObject *oneObject in objects) {
        int lineNum = [[oneObject valueForKey:kLineNumberKey] intValue];
        NSString *lineText = [oneObject valueForKey:kLineTextKey];
        
        UITextField *theField = self.lineFields[lineNum];
        theField.text = lineText;
    }
    
    UIApplication *app = [UIApplication sharedApplication];
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(applicationWillResignActive:)
     name:UIApplicationWillResignActiveNotification
     object:app];
}

- (void)applicationWillResignActive:(NSNotification *)notification
{
    BIDAppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    NSManagedObjectContext *context = [appDelegate managedObjectContext];
    NSError *error;
    for (int i = 0; i < 4; i++) {
        UITextField *theField = self.lineFields[i];
        
        NSFetchRequest *request = [[NSFetchRequest alloc]
                                   initWithEntityName:kLineEntityName];
        
        NSPredicate *pred = [NSPredicate
                             predicateWithFormat:@"(%K = %d)", kLineNumberKey, i];
        [request setPredicate:pred];
        
        NSArray *objects = [context executeFetchRequest:request error:&error];
        if (objects == nil) {
            NSLog(@"There was an error!");
            // Do whatever error handling is appropriate
        }
        
        NSManagedObject *theLine = nil;
        if ([objects count] > 0) {
            theLine = [objects objectAtIndex:0];
        } else {
            theLine = [NSEntityDescription
                       insertNewObjectForEntityForName:kLineEntityName
                       inManagedObjectContext:context];
        }
        
        [theLine setValue:[NSNumber numberWithInt:i] forKey:kLineNumberKey];
        [theLine setValue:theField.text forKey:kLineTextKey];
        
    }
    [appDelegate saveContext];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end